Forum Moderators: phranque

Message Too Old, No Replies

Simple redirect

mod_rewrite error.

         

Orangeyness

8:49 am on Aug 26, 2008 (gmt 0)

10+ Year Member



I have used mod_rewrite before a few times with no problems. However I just tried to set up a simple-ish redirect and it isn't working...


RewriteEngine On
RewriteRule ^/p/(.*)$ /index.php?page=$1

Its quite basic its meant to redirect a link like "www.foobar.com/p/bla" to "www.foobar.com/index.php?page=bla"... But it doesn't instead it just gives me a 404 error. The funny thing is if i remove the '/p/' part it works. But than it redirects all requests.

Probably a simple mistake but I have looked at it for ages and can't figure out what it is...

Thanks guys.

jdMorgan

5:52 pm on Aug 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If this code goes into a .htaccess file, then the path to that .htaccess file's directory will be stripped from the URL-path tested by RewriteRule.

In simple terms, if the code is in example.com/.htaccess, then the URL-path pattern should be "^p/(.*)$" because the path to this .htaccess file is "/".

Jim

Orangeyness

4:34 am on Aug 27, 2008 (gmt 0)

10+ Year Member



Arr... Why didn't I try that. Thanks a lot.

g1smd

1:49 pm on Aug 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




*** ...its meant to redirect a link like... ***

By the way, this isn't a redirect.

It is a rewrite.