0

I want to mod-rewrite url and i am just wondering how do i rewrite my url of querystring type

http://localhost/folder/index.php?param1=value1&param2=value2&param3=value3 

into

http://localhost/folder/value1/value2/value3

I have this htaccess file please tell me if it correct

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^index/(w+)/(w+)/(w+)$ /index.php?param1=$1&param2=$2&param3=$3 [nc]

1 Answer 1

1

Use this code in your DOCUMENT_ROOT's .htaccess file:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{QUERY_STRING} !param1= [NC]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)$ $1/index.php?param1=$2&param2=$3&param3=$4 [QSA,L]
Sign up to request clarification or add additional context in comments.

2 Comments

thanks for reply but i am not able to run since it is going in infinite redirection loop. Is just entering localhost/folder/value1/value2/value3 will show me the result? And i forgot to tel that my param1 is global variable i am passing the value directly through url while other param are taken from an array.
Please check my updated answer (I added a RewriteCond to prevent looping). And yes you need to enter http://localhost/folder/value1/value2/value3 to test it. Above URL will load http://localhost/folder/index.php?param1=value1&param2=value2&param3=value3 internally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.