Jump to content

Recommended Posts

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.

 

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.

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

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 ?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.