unemployment Posted August 11, 2011 Share Posted August 11, 2011 I'm trying to make... http://mysite.com/blog.php?post_id=22 to... http://mysite.com/blog/title-of-the-blog-post with the rewrite rule below but it fails on me. RewriteRule ^blog/([^/]+)/?$ /blog.php?post_id=$1 [L] Quote Link to comment https://forums.phpfreaks.com/topic/244472-blog-rewrite-fails/ Share on other sites More sharing options...
cags Posted August 11, 2011 Share Posted August 11, 2011 More details required. The rule you have looks like it will successfully serve up /blog.php?post_id=title-of-the-blog-post if the user requests /blog/title-of-the-blog-post , if you are expecting it to do more than that, it won't. Quote Link to comment https://forums.phpfreaks.com/topic/244472-blog-rewrite-fails/#findComment-1255709 Share on other sites More sharing options...
unemployment Posted August 11, 2011 Author Share Posted August 11, 2011 I'd like for it to change the url when you visit current one, but I suppose that might be too much to ask? Quote Link to comment https://forums.phpfreaks.com/topic/244472-blog-rewrite-fails/#findComment-1255793 Share on other sites More sharing options...
cags Posted August 11, 2011 Share Posted August 11, 2011 It's certainly not going to work with just what you have. You could add another rule to make that rewrite, the problem with doing that is that you end up with an infinite loop. When somebody visits existing they get redirected to new, which get's rewritten to existing which gets redirected to new... and you end up with an infinite loop. There are hacky ways around it, but I'm yet to come across a neat way. Quote Link to comment https://forums.phpfreaks.com/topic/244472-blog-rewrite-fails/#findComment-1255828 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.