How to successfully Rewrite a URL with .htaccess
I am trying to rewrite mysite.com/broadcasts to mysite.com/feed so that it will show up in the location bar as "broadcasts" but actually go to /feed.
Here is what I have in the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^broadcasts(/)?$ /feed/
</IfModule>
But this isn't working... I get a 404 error.
Wondering if I'm doin开发者_开发技巧g something stupidly wrong.
Thanks!
Here's how you do it:
RewriteRule ^(.*)/broadcasts$ $1/feed/
This will make sure no matter what domain you use, it will always be matched if you have the right combination, making it easier if in the future you decide to change domains for example.
UPDATE I accidentally used (.*) twice on my example, but it has been fixed
Hope this helps you
remove trailing / from /feeds/ ;-)
at least - this works for me right now
Add
RewriteRule ^broadcasts feed
in your .htaccess file.
If it doesn't work, try add
RewriteEngine on
RewriteBase /
in the top of your file.
精彩评论