shanejeffery86 Posted June 28, 2010 Share Posted June 28, 2010 Hey all. I am just stumped and cannot figure out what I am doing wrong. I thought I understood the basics of mod_rewrite and rewrite rules as I did a pretty bangup job on another site. But, now, I cannot get the rules to work on a new site. Here is what I have going on in my .htaccess: Options +FollowSymLinks RewriteEngine On RewriteRule ^buy-wow-account/account/([0-9]+)/$ /character.php?acc_id=$1 [R] RewriteRule ^buy$ /buy.php [R] RewriteRule ^sell$ /sell.php [R] RewriteRule ^feedback$ /feedback.php [R] RewriteRule ^aboutus$ /about.php [R,L] I have checked with my host and mod_rewrite is installed on the server and properly configured. So, that is not the problem. Any ideas on what the heck I am doing wrong? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/206021-rewrite-not-working/ Share on other sites More sharing options...
cags Posted June 28, 2010 Share Posted June 28, 2010 You tell us, what IS the problem? Assumably something isn't working how you expect, but since you haven't stated what we can't help you. The code you have posted will redirect http://domain/buy-wow-account/account/20/ to http://domain/character.php?acc_id=20, etc. Quote Link to comment https://forums.phpfreaks.com/topic/206021-rewrite-not-working/#findComment-1078070 Share on other sites More sharing options...
shanejeffery86 Posted June 28, 2010 Author Share Posted June 28, 2010 Hey there again Cags. The rewrite is not happening whatsoever. So, I have something wrong with my rules. The code you have posted will redirect http://domain/buy-wow-account/account/20/ to http://domain/character.php?acc_id=20, etc. My understanding is that you have it backwards. I am trying to get it to recognize http://domain/character.php?acc_id=20 and rewrite it to http://domain/buy-wow-account/account/20/. Quote Link to comment https://forums.phpfreaks.com/topic/206021-rewrite-not-working/#findComment-1078316 Share on other sites More sharing options...
shanejeffery86 Posted June 28, 2010 Author Share Posted June 28, 2010 Example: RewriteRule ^buy/$ /buy.php [L] The links to buy.php should show up as buy/, but it does not. Still shows buy.php. Quote Link to comment https://forums.phpfreaks.com/topic/206021-rewrite-not-working/#findComment-1078321 Share on other sites More sharing options...
cags Posted June 28, 2010 Share Posted June 28, 2010 That's because it's you that has it backwards. A RewriteRule is simply an Alias, that allows you to use the pattern matched in the first half as a valid link to the second. ^buy/$ /buy.php [L] Will take requests for http://domain/buy/ and serve up http://domain/buy.php. To test this rule you would have to enter http://domain/buy/ in the address bar, or have a link that has a href of http://domain/buy/ Quote Link to comment https://forums.phpfreaks.com/topic/206021-rewrite-not-working/#findComment-1078330 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.