www到非www重定向问题

I am using .htaccess to redirect from www.test123.com to non http://test123.com site. Because it cause the cross domain issue in Ajax. I am not able to use www.test123.com in Ajax(returns 500 error).

So, i used this code in .htaccess file

RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) http://%1/$1 [R=301,NE,L]

And all thing is working great. Now issue is, i have unity app which calling php file like this

http://www.test123.com/save.php

And posting some variables with this URL also. so i am not able to get that post data because this will redirect from www.test123.com to http://test123.com. So i lost post data. What should i do to get my post data?

You should ignore POST method from your redirect rule as POST data does get lost while doing a full redirect.

RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) http://%1/$1 [R=301,NE,L]