Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.