.htaccess rewrite rule with multiple variables

Programming
Tutor: None Selected Time limit: 1 Day

Hi,

sorry i'm really bad skilled in .htaccess but i need to do this:

I need to have URL in this format:

http://www.domain.com/test/accomodation/search/?variable_2=aaa&variable_3=bbb

and the first variable is "accomodation" between slashes. I don't know how many variable i need after last slash, but as many as possible.

I tried something like this, but it doesn't work... Yes it work, but i can get any variable after last slah...

RewriteRule ^(accomodation)/search/(.*) accomodation.php?title_url=$1

Nov 30th, -0001
I see. So you are trying to change all ?= to "/"?
Before we do .htaccess, I need to know that are you using any PHP/Python framework?
Jun 12th, 2013

No i dont use any php framework

Jun 13th, 2013

Try out this:

<IfModulemod_rewrite.c>
RewriteEngine On
RewriteRule ^lookup/([a-z0-9\-]+)/item/?$ /lookup.php?id=$1
</IfModule>

This will match any alphanumeric (also will recognise dashes) string of any length as the 'id'. You can limit this to just numeric by changing the regex to ([0-9]+).

<IfModulemod_rewrite.c>
RewriteEngine On
RewriteRule ^lookup/([a-z0-9\-]+)/([a-z0-9\-]+)/?$ /lookup.php?id=$1&view=$2
</IfModule>

This one will match /lookup/123/some-text/ to /lookup.php?id=123&view=some-text


Jun 13th, 2013

Are you studying on the go? Check out our FREE app and post questions on the fly!
Download on the
App Store
...
Nov 30th, -0001
...
Nov 30th, -0001
Dec 2nd, 2016
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer