Reputation: 285
hope you people doing well ! what will be Best way to redirect www.example.com to example.com.
I have used .htaccess ,but its giving me problem in Jquery POST call ..
So now i am confused which method i can use for redirecting www
Thanks in advance.
Upvotes: 2
Views: 211
Reputation: 143876
You can't 301 redirect a POST request without losing the request's body, which is probably why you're getting jquery errors. You can either ensure jquery requests have the "www." in the hostname removed, or you only redirect for GET
or HEAD
requests:
RewriteCond %{REQUEST_METHOD} (GET|HEAD)
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R]
Upvotes: 4