Tony Friz
Tony Friz

Reputation: 893

Can't seem to get mod_rewrite to behave the way I need it to

I'm dealing with a server that has mod_rewrite enabled but I can't seem to get any rewrites to work except one...

The following works

RewriteEngine on 

RewriteRule (.*) /test.php [R=301,L]

But obviously creates an endless loop back to test.php. So if I type website.com/something, it's being redirected to test.php which is then redirected to itself endlessly.

However, something like this isn't working:

RewriteEngine on 

RewriteRule /something.html /something.php [R=301,L]

Any ideas what I'm doing wrong?

Upvotes: 0

Views: 20

Answers (1)

unconnected
unconnected

Reputation: 1011

I think you need to add base and supply base symbol (^) to rule.

RewriteEngine on
RewriteBase /
RewriteRule ^something.html /something.php [R=301,L]
RewriteRule ^(.*) /test.php [L] #this rule must not issue 301 redirect

Upvotes: 1

Related Questions