3

Suppose I have URLs with query string parameters like these:

index.php?lag=en&name=About Us&itemid=60
index.php?host=consumer&lag=en&name=About Us&itemid=64

Using mod_rewrite, how can I redirect them like these?

en_About Us_60.php
consumer/en_About Us_64.php

In the Above urls values are dynamic.

CharlesB
  • 86,532
  • 28
  • 194
  • 218
pradeep
  • 56
  • 4
  • I'm quite sure you mean the contrary, you want url to be shown in the en_About Us_60.php for the user and redirected to index.php?lag=en&name=About Us&itemid=60 fot the application, isn't it? And are you sure you want a redirect or just a transparent rewrite? – regilero Oct 14 '11 at 07:21
  • Yep, I want to be redirect index.php?lag=en&name=About Us&itemid=60 index.php?host=consumer&lag=en&name=About Us&itemid=64 these two dynamic url to static url like en_About Us_60.php consumer/en_About Us_64.php this.Please help me – pradeep Oct 15 '11 at 04:11
  • you say yes and then you say the contrary of my sentence... write in your question the url for the user and the url for your app. Do you have a en_About Us_64.php file? – regilero Oct 15 '11 at 07:16

1 Answers1

0

Something like this:

RewriteEngine on 
RewriteCond %{QUERY_STRING} host=(.*)&lag=(.*)&name=(.*)&itemid=(.*)
RewriteRule ^index.php(.*)$ /%1/%2_%3_%4 [QSA]

RewriteCond %{QUERY_STRING} lag=(.*)&name=(.*)&itemid=(.*)
RewriteRule ^index.php(.*)$ /%1_%2_%3 [QSA]

Remember, to check all the statements, which are possible ;)

Keenora Fluffball
  • 1,647
  • 2
  • 18
  • 34