views:

65

answers:

3

Hello.

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 doing something stupidly wrong.

Thanks!

A: 

remove trailing / from /feeds/ ;-)

at least - this works for me right now

zerkms
A: 

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

Marcos Placona
domain is not passed in URI in mod_rewrite
zerkms
But this makes sure whatever is before it, is matched.
Marcos Placona
for url mysite.com/broadcasts your (.*) will always equals to empty string. so for constant url it's ambiguous.
zerkms
Yes, but if for instance he decides to create a parent folder, it will come in handy, and is already future proof
Marcos Placona
And the $1 means that whatever was before the /feed/ will be before the /broadcasts/ eh?
Ian Storm Taylor
Hmm... I've tried both ways and they are not working... might it be because I am using Wordpress? And it has its own rewrities as well? I put this one before them in the .htaccess file though...
Ian Storm Taylor
Is it still 404'ing then? Weird, coz this should work wherever it's placed.
Marcos Placona
A: 

Add


RewriteRule ^broadcasts feed
in your .htaccess file. If it doesn't work, try add

RewriteEngine on
RewriteBase /
in the top of your file.

jocap