let's say i have a url of the form: myurl.com/index.php?m=1 and i want to map it to myurl.com/aboutus, that means, i want the browser to show the latter url in the bar above. so what i do first is to catch aboutus and map it to inde开发者_如何学运维x.php?m=1.
RewriteRule ^aboutus$ /index.php?m=1
now if i type myurl.com/aboutus, the proper page is shown, BUT i wanna have it the opposite way as well, so even when i type /index.php?m=1, i want the browser to show /aboutus.
how can i achieve that with mod_rewrite?
any help is appreciated!
cheers,
bRewriteEngine on
RewriteCond %{QUERY_STRING} =m=1
RewriteCond %{REQUEST_URI} =/index.php
RewriteRule ^.* /aboutus? [R=301]
RewriteRule ^aboutus /index.php?m=1 [QSA]
Update #1
RewriteEngine on
RewriteCond %{QUERY_STRING} =m=1
RewriteCond %{REQUEST_URI} =/index.php
RewriteRule ^.* /kepek? [R=301]
RewriteCond %{QUERY_STRING} =m=2
RewriteCond %{REQUEST_URI} =/index.php
RewriteRule ^.* /paroknak? [R=301]
RewriteCond %{QUERY_STRING} =m=3
RewriteCond %{REQUEST_URI} =/index.php
RewriteRule ^.* /magam? [R=301]
RewriteCond %{QUERY_STRING} =m=4
RewriteCond %{REQUEST_URI} =/index.php
RewriteRule ^.* /kapcsolat? [R=301]
RewriteRule ^kepek /index.php?m=1&redirected=1 [QSA]
RewriteRule ^paroknak /index.php?m=2&redirected=1 [QSA]
RewriteRule ^magam /index.php?m=3&redirected=1 [QSA]
RewriteRule ^kapcsolat /index.php?m=4&redirected=1 [QSA]
Are you looking to map numbers to pages like 1->about, 2->news...?
Also, your desired behavior sounds like an infinite redirect loop.
RewriteRule ^aboutus$ /index.php?m=1 [L]
RewriteRule ^index.php\?m=1$ /aboutus [301,L]
精彩评论