301 Redirect index.php?dir= to a folder?
Frage
I want to redirect the following
http://www.example.com/folder/index.php?dir=Dir1
http://www.example.com/folder/index.php?dir=Dir1/Dir2
to
http://www.example.com/folder/Dir1
http://www.example.com/folder/Dir1/Dir2
I want to "301 Redirect" it NOT "Rewrite" i.e I want the "index.php?dir=" link to 301 redirect to folder structure.
Please advice?
Lösung
Do this in your DocumentRoot .htaccess
.
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
RewriteCond %{QUERY_STRING} ^dir=(.*)$ [NC]
RewriteRule ^ folder/%1? [L,R=301]
RewriteRule ^folder/(.+)/? folder/index.php?dir=$1 [L,QSA]
Andere Tipps
RewriteCond %{QUERY_STRING} ^dir=(.*)$
RewriteRule ^folder/index\.php$ folder/%1 [L,R=302]
change to 301 once working.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow