301 redirect is working for www.example.com but not for
I am getting a strange problem with 301 redirect it the code is working for with www in the link and not working for with out www
RewriteBase /
RewriteRule ^api$ http://example.com/topic/api [R=301,L]
if i type http://www.example.com/api it works but if i do http://example.com/api it doesnt work
A开发者_运维知识库dv thanks prasanth
Check your Virtual Host configuration should be like below
<VirtualHost *:80>
...
ServerName www.example.com
ServerAlias example.com
...
</VirtualHost>
If the page is not found, it is possible that the example.com and www.example.com point to difference directory, otherwise, example.com may not linked to any place yet.
精彩评论