Jump to content

Mod ReWrite


gerkintrigg

Recommended Posts

I dunno whether I'm being stupid here, but I have this rewrite rule and I have no idea why it's just not doing anything (at all)

 

RewriteRule ^products/([^/\.]+)?$ http://sary.co.uk/products/reader.php?id=$1.php?id=$1 [L]

 

the error pages work fine, so I think HTACCESS support is live.

Link to comment
https://forums.phpfreaks.com/topic/239001-mod-rewrite/
Share on other sites

1) I should have a rewrite engine - I do on other sites on the same server, but this site is very new and I have to admit that I never used it before.

2) The URL I'm trying to match is http://www.sary.co.uk/products/2_Product-2.html to http://www.sary.co.uk/products/reader.php?id=2

3) This should now be a working URL - I know I had a small code error in the destination URL, but that shouldn't have effected the mod re-write rule.

Link to comment
https://forums.phpfreaks.com/topic/239001-mod-rewrite/#findComment-1228071
Share on other sites

1. By "a RewriteEngine" I mean a

RewriteEngine on

in your .htaccess. Without it your RewriteRules won't activate.

 

3. The part in the destination URL (in your first post) I was referring to is

?id=$1.php?id=$1

While technically valid, I didn't think you meant that.

 

Try this:

RewriteRule ^/?products/(\d+)_(.*)\.html$ products/reader.php?id=$1 [L]

Link to comment
https://forums.phpfreaks.com/topic/239001-mod-rewrite/#findComment-1228173
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.