bearsfoot Posted November 20, 2009 Share Posted November 20, 2009 Hi All, I currently have the following in my .htaccess RewriteEngine on Options +FollowSymLinks RewriteRule index/(.*)/(.*)/$ /index.php?$1=$2 RewriteRule index/(.*)/(.*)/(.*)/(.*)/$ /index.php?$1=$2&$3=$4 http://www.thesite.com/index/view/products/ ==> http://www.thesite.com/index.php?view=products and http://www.thesite.com/index/view/products/id/1 ==> http://www.thesite.com/index.php?view=products&id=1 Can someone please help with addition rules so the following urls would work. I want to remove the 'index' and parameter name portions Eg .. The desired result is http://www.thesite.com/products and http://www.thesite.com/products/1 Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/182275-help-with-rewrite-for-sef-urls-partially-working/ Share on other sites More sharing options...
bearsfoot Posted November 20, 2009 Author Share Posted November 20, 2009 Sorry, I thought both the rewrite rules were working together but they are not. If I use the rule catering for 2 params, then the url with a single param doesn't work. And I get a File does not exist: index error in the apache error log. Quote Link to comment https://forums.phpfreaks.com/topic/182275-help-with-rewrite-for-sef-urls-partially-working/#findComment-961835 Share on other sites More sharing options...
cags Posted November 20, 2009 Share Posted November 20, 2009 If these's are the eventual URL's that you wish your visitors to see... http://www.thesite.com/products http://www.thesite.com/products/1 ...and these are the pages you wish your visitors to actually see... http://www.thesite.com/index.php?view=products http://www.thesite.com/index.php?view=products&id=1 Then your going to want something along the lines of... Options +FollowSymLinks RewriteEngine On RewriteRule ^([^/]+)/?$ /index.php?view=$1 RewriteRule ^([^/]+)/([^/]+)/?$ /index.php?view=$1&id=$2 Quote Link to comment https://forums.phpfreaks.com/topic/182275-help-with-rewrite-for-sef-urls-partially-working/#findComment-961866 Share on other sites More sharing options...
bearsfoot Posted November 21, 2009 Author Share Posted November 21, 2009 Hi, Thanks for the reply. I have tried implementing just the first rule initially but get the following error requesting any page .. Request exceeded the limit of 10 internal redirects due to probable configuration error Also, How would those two rules work together ? Wouldn't the first condition always be met breaking the 2nd rule ? When should I look at using the [L] option ? Quote Link to comment https://forums.phpfreaks.com/topic/182275-help-with-rewrite-for-sef-urls-partially-working/#findComment-962268 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.