pneudralics Posted April 30, 2009 Share Posted April 30, 2009 Trying to attempt to mod rewrite but just getting error 500. What I'm trying to get is: backgrounds/Animals/Birdy/29 So will the first set of A-Z replace Animals or category? If it replaces Animals..does it just ignore category? RewriteEngine on RewriteBase / RewriteRule ^backgrounds/([A-Z]+)/([A-Z]+)/([0-9]+)$ backgroundsimage.php?category=Animals&title=Birdy&id=29 Link to comment https://forums.phpfreaks.com/topic/156219-solved-what-is-wrong-with-my-mod-rewrite/ Share on other sites More sharing options...
gffg4574fghsDSGDGKJYM Posted April 30, 2009 Share Posted April 30, 2009 Options +FollowSymLinks <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^backgrounds/([A-Z]+)/([A-Z]+)/([0-9]+)(/?)$ backgroundsimage.php?category=$1&title=$2&id=$3 [NC,L] </IfModule> This code actually work (tested). I replace the GET value with $var. Added (/?) in the regular expression so you can use both with or without a trailling slash like that : http://www.example.com/backgrounds/animals/birds/70/ http://www.example.com/backgrounds/animals/birds/70 Added a NC flag mean case insensitive (no case) Added L flag mean when it match pattern apply it and stop there (don't read other rules in .htaccess) My best guess is that you are missing the 'Options +FollowSymLinks' needed by mod_rewrite or mod_rewrite isn't installed. Link to comment https://forums.phpfreaks.com/topic/156219-solved-what-is-wrong-with-my-mod-rewrite/#findComment-822517 Share on other sites More sharing options...
pneudralics Posted April 30, 2009 Author Share Posted April 30, 2009 Where did you test it? I tried WAMPSERVER AND XAMMP and it still doesn't work. I don't get any errors, it just doesn't rewrite. Link to comment https://forums.phpfreaks.com/topic/156219-solved-what-is-wrong-with-my-mod-rewrite/#findComment-822761 Share on other sites More sharing options...
nadeemshafi9 Posted April 30, 2009 Share Posted April 30, 2009 Where did you test it? I tried WAMPSERVER AND XAMMP and it still doesn't work. I don't get any errors, it just doesn't rewrite. what do you do in order to try it ? Link to comment https://forums.phpfreaks.com/topic/156219-solved-what-is-wrong-with-my-mod-rewrite/#findComment-822762 Share on other sites More sharing options...
pneudralics Posted April 30, 2009 Author Share Posted April 30, 2009 Where did you test it? I tried WAMPSERVER AND XAMMP and it still doesn't work. I don't get any errors, it just doesn't rewrite. what do you do in order to try it ? Click on the links on the page that are dynamic.. When I type it in the browser it works. Now if I have this: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^backgrounds/$ backgrounds.php [NC,L] </IfModule> and I type http://localhost/backgrounds/ all my links are now under the backgrounds directory so none work anymore. Isn't mod_rewrite suppose to rewrite the url so if I type http://localhost/backgrounds.php it'll change that to http://localhost/backgrounds/ ? Link to comment https://forums.phpfreaks.com/topic/156219-solved-what-is-wrong-with-my-mod-rewrite/#findComment-822789 Share on other sites More sharing options...
pneudralics Posted April 30, 2009 Author Share Posted April 30, 2009 and if I hover over links it'll say backgrounds/ instead of backgrounds.php Link to comment https://forums.phpfreaks.com/topic/156219-solved-what-is-wrong-with-my-mod-rewrite/#findComment-822806 Share on other sites More sharing options...
wildteen88 Posted April 30, 2009 Share Posted April 30, 2009 mod_rewrite will not rewrite urls already within a webpage. You have to modify your urls manually. Link to comment https://forums.phpfreaks.com/topic/156219-solved-what-is-wrong-with-my-mod-rewrite/#findComment-822892 Share on other sites More sharing options...
pneudralics Posted May 1, 2009 Author Share Posted May 1, 2009 mod_rewrite will not rewrite urls already within a webpage. You have to modify your urls manually. .htaccess file now have this in it RewriteRule ^backgrounds/(.*)$ backgroundscategory.php?category=$1 [NC,L] php file with links now have this echo "<a href=\"backgrounds/$categorylink\" class=\"backgroundsfg\">$categorylink</a><br />"; Everytime I click on the link it keeps adding backgrounds/...so my url will eventually look like: http://localhost/backgrounds/backgrounds/backgrounds/backgrounds/category Link to comment https://forums.phpfreaks.com/topic/156219-solved-what-is-wrong-with-my-mod-rewrite/#findComment-823149 Share on other sites More sharing options...
pneudralics Posted May 1, 2009 Author Share Posted May 1, 2009 Got it. Did this: echo "<a href=\"/backgrounds/$categorylink\" class=\"backgroundsfg\">$categorylink</a><br />"; Link to comment https://forums.phpfreaks.com/topic/156219-solved-what-is-wrong-with-my-mod-rewrite/#findComment-823242 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.