gerkintrigg Posted June 10, 2011 Share Posted June 10, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/239001-mod-rewrite/ Share on other sites More sharing options...
requinix Posted June 10, 2011 Share Posted June 10, 2011 1. Do you have a RewriteEngine? Are you allowed .htaccess files? 2. What URL are you trying to match? 3. Your destination address probably isn't right (at least not the one in your post). Quote Link to comment https://forums.phpfreaks.com/topic/239001-mod-rewrite/#findComment-1228055 Share on other sites More sharing options...
gerkintrigg Posted June 10, 2011 Author Share Posted June 10, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/239001-mod-rewrite/#findComment-1228071 Share on other sites More sharing options...
requinix Posted June 11, 2011 Share Posted June 11, 2011 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] Quote Link to comment https://forums.phpfreaks.com/topic/239001-mod-rewrite/#findComment-1228173 Share on other sites More sharing options...
gerkintrigg Posted June 11, 2011 Author Share Posted June 11, 2011 Ah! it works. To reply directly to your points: 1) Yes. 2) D'oh! 2) Sorted. Thanks very much. ) Quote Link to comment https://forums.phpfreaks.com/topic/239001-mod-rewrite/#findComment-1228414 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.