Forum Moderators: phranque

Message Too Old, No Replies

Mod Rewrite Rule Help

Mod_rewrite

         

jgeek

6:26 pm on Jun 20, 2008 (gmt 0)

10+ Year Member



Hi
I want to redirect every request of the type :
[local:80...] (nn is a number)

to

[local:80...] (nn from above)

For example:

Redirect URL

[local:80...]

to

[local:80...]

The rule that I wrote is mentioned below:

RewriteRule ^([^/\.]+)/?$ /shop/catalog.php?prodid=$1 [L]

But this doesn't seem to be working though I have enabled the required config on Apache (tested it through htaccess by doing a hardcode url redirect). What is that I'm doing wrong ? Can someone please help ?
Thank you.

jdMorgan

4:10 pm on Jun 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Note that this is an internal URL-to-filepath rewrite, and not an external URL-to-URL redirect.

If you are specifically looking for numbers, then I'd suggest:


RewriteRule ^([0-9]+)/?$ /shop/catalog.php?prodid=$1 [L]

But you might want to try a simple test first, to determine if mod_rewrite is working at all on your server:

RewriteRule ^foo\.html$ http://www.google.com/ [R=302,L]

Request the page "/foo.html" from your server, and you should land at google.

I'm not sure if you've got all the required set-up lines in your code: You may need one or both of the following lines ahead of your rule:


Options +FollowSymLinks
RewriteEngine on

Jim