BUX Posted October 21, 2011 Share Posted October 21, 2011 I have tried to created friendly urls by editing the .htaccess file and writing in it: RewriteEngine On RewriteBase /SITES/Starservice/ RewriteRule ^home/([^/]+).html home.php?page=$1 [L] RewriteRule ^home/([^/]+)/([^/]+).html home.php?page=$1&vettura=$2 [L] RewriteRule ^home/([^/]+)/([^/]+)/([^/]+).html home.php?page=$1&vettura=$2&cat=$3 [L] RewriteRule ^home/([^/]+)/([^/]+)/([^/]+)/([^/]+).html home.php?page=$1&vettura=$2&cat=$3<b=$4 [L] and have changed my links into home/offerte.html home/offerte/eurocargo.html ecc. The problem is that every time i click on a link the links in the following page (which should be the same) stack another home/ creating links like: home/offerte.html home/home/offerte.html home/home/home/offerte.html as you can see from the rewriterules the page (home) is always the same but depending on where the link is from it has more or less variables passed. How do i have to code the rules to make it work properly? thank in advance Quote Link to comment https://forums.phpfreaks.com/topic/249546-help-with-rewrite/ Share on other sites More sharing options...
BUX Posted October 21, 2011 Author Share Posted October 21, 2011 another problem showed up, once i create the .htaccess file the folder which is contained in (the site folder) it disappears to apache! is not visible anymore and gives 404! Quote Link to comment https://forums.phpfreaks.com/topic/249546-help-with-rewrite/#findComment-1281187 Share on other sites More sharing options...
requinix Posted October 21, 2011 Share Posted October 21, 2011 1. You have to change your links (not your .htaccess) to use the correct path, like foo/bar 2. What URL are you trying to browse to that gives the 404? Quote Link to comment https://forums.phpfreaks.com/topic/249546-help-with-rewrite/#findComment-1281215 Share on other sites More sharing options...
BUX Posted October 21, 2011 Author Share Posted October 21, 2011 I dont get the 404 that was a problem i solved. I did change my links and they all look like : home/foo/bar home/foo/bar/gig home/foo/bar/gig/tak ecc The weird thnig is that every time i use one of these links, the links in the following page stack a home/ inside so they look: home/home/foo/bar home/home/foo/bar/gig home/home/foo/bar/gig/tak and after i click on any of these in the next page they become: home/home/home/foo/bar home/home/home/foo/bar/gig home/home/home/foo/bar/gig/tak dont i have to put a rewritecond to check how many sub cat are in the url? so to check if its home/foo or home/foo/bar or home/foo/bar/gig ? I dont know if its the right solution but even if it is i dont know how to apply it ^^ help! Quote Link to comment https://forums.phpfreaks.com/topic/249546-help-with-rewrite/#findComment-1281219 Share on other sites More sharing options...
requinix Posted October 21, 2011 Share Posted October 21, 2011 That's the wrong solution. The URLs need to be the full and absolute path to the page. That means it will look nearly exactly like what I posted: leading slash and SITES/Starservice included. Quote Link to comment https://forums.phpfreaks.com/topic/249546-help-with-rewrite/#findComment-1281225 Share on other sites More sharing options...
BUX Posted October 21, 2011 Author Share Posted October 21, 2011 am i supposed to erase the following string from .htaccess? RewriteBase /sites/Starservicerent/ and no condition is needed then? Quote Link to comment https://forums.phpfreaks.com/topic/249546-help-with-rewrite/#findComment-1281231 Share on other sites More sharing options...
requinix Posted October 21, 2011 Share Posted October 21, 2011 That has nothing to do with what I'm saying. You have links that look like Those need to be Quote Link to comment https://forums.phpfreaks.com/topic/249546-help-with-rewrite/#findComment-1281245 Share on other sites More sharing options...
BUX Posted October 22, 2011 Author Share Posted October 22, 2011 thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/249546-help-with-rewrite/#findComment-1281350 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.