amwd07 Posted May 3, 2008 Share Posted May 3, 2008 I have tried to use htaccess to get the following to work with or without trailing slash maybe there is another way to do this via PHP ??? Currently the following rule works but only without the trailing slash #RewriteRule ^([^.]+)/([^.]+)$ /dynamic.php?feature=$1§ion=$2 [L] www.example.co.uk/$1 www.example.co.uk/$1/$2 /// these 2 work www.example.co.uk/$1/ www.example.co.uk/$1/$2/ /// these ones don't & unfortuntly google results show the trailing slash the error displayed with trailing slash: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 I'm not sure if this is a PHP issue or Htaccess (possibly both?) previous modrewite post here http://www.phpfreaks.com/forums/index.php/topic,195423.0.html Quote Link to comment https://forums.phpfreaks.com/topic/104007-solved-mod-rewrite-alternative/ Share on other sites More sharing options...
BlueSkyIS Posted May 3, 2008 Share Posted May 3, 2008 i would strip off the trailing slash via htaccess, then the non-slash rules should work. Quote Link to comment https://forums.phpfreaks.com/topic/104007-solved-mod-rewrite-alternative/#findComment-532454 Share on other sites More sharing options...
amwd07 Posted May 3, 2008 Author Share Posted May 3, 2008 Thank you for your reply I have tried doing this but it effects the other rule, but your right it removes the trailing slash but for some reason the dining rule now fails ? #Removes trailing slash from URL RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L] RewriteRule ^([^.]+)$ /dynamic.php?feature=$1 [L] RewriteRule ^([^.]+)/dining dining.php?town=$1 [L] Quote Link to comment https://forums.phpfreaks.com/topic/104007-solved-mod-rewrite-alternative/#findComment-532457 Share on other sites More sharing options...
BlueSkyIS Posted May 3, 2008 Share Posted May 3, 2008 maybe you need to define dining as the end of the string? RewriteRule ^([^.]+)/dining$ /dining.php?town=$1 [L] Quote Link to comment https://forums.phpfreaks.com/topic/104007-solved-mod-rewrite-alternative/#findComment-532459 Share on other sites More sharing options...
amwd07 Posted May 3, 2008 Author Share Posted May 3, 2008 I now getting an Internal Server Error for the entire site? Quote Link to comment https://forums.phpfreaks.com/topic/104007-solved-mod-rewrite-alternative/#findComment-532461 Share on other sites More sharing options...
amwd07 Posted May 3, 2008 Author Share Posted May 3, 2008 sorry my mistake no internal serve error mispelt one of the words. still not working with this rule Quote Link to comment https://forums.phpfreaks.com/topic/104007-solved-mod-rewrite-alternative/#findComment-532464 Share on other sites More sharing options...
BlueSkyIS Posted May 3, 2008 Share Posted May 3, 2008 you'll need to move the dining line above the other one because the other one matches anything, so dining will never be reached unless it is first. #Removes trailing slash from URL RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L] RewriteRule ^([^.]+)/dining$ /dining.php?town=$1 [L] RewriteRule ^([^.]+)$ /dynamic.php?feature=$1 [L] Quote Link to comment https://forums.phpfreaks.com/topic/104007-solved-mod-rewrite-alternative/#findComment-532466 Share on other sites More sharing options...
amwd07 Posted May 3, 2008 Author Share Posted May 3, 2008 Genius it works the only other small issue is with the bottom 2 lines the first rule works but the second one doesn't ? #Removes trailing slash from URL RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L] RewriteRule ^([^.]+)/dining$ /dining.php?town=$1 [L] RewriteRule ^dining/([^.]+)-([^.]+)\.php$ dining.php?county=$1&town=$2 [R,L] RewriteRule ^([^.]+)/eatingout/([^.]+) eatingout.php?town=$1&accountname=$2 [L] RewriteRule ^([^.]+)$ /dynamic.php?feature=$1 [L] RewriteRule ^([^.]+)/([^.]+)$ /dynamic.php?feature=$1§ion=$2 [L] Quote Link to comment https://forums.phpfreaks.com/topic/104007-solved-mod-rewrite-alternative/#findComment-532471 Share on other sites More sharing options...
BlueSkyIS Posted May 3, 2008 Share Posted May 3, 2008 try switching the order of the bottom 2. ^([^.]+)$ will be a much broader match, so it needs to go second. Quote Link to comment https://forums.phpfreaks.com/topic/104007-solved-mod-rewrite-alternative/#findComment-532474 Share on other sites More sharing options...
amwd07 Posted May 3, 2008 Author Share Posted May 3, 2008 Simple but effective works 10/10 for support Thank you BlueSky Quote Link to comment https://forums.phpfreaks.com/topic/104007-solved-mod-rewrite-alternative/#findComment-532477 Share on other sites More sharing options...
amwd07 Posted May 3, 2008 Author Share Posted May 3, 2008 where is the option for Topic solved? Quote Link to comment https://forums.phpfreaks.com/topic/104007-solved-mod-rewrite-alternative/#findComment-532481 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.