Stiller Eugen
Stiller Eugen

Reputation: 701

htaccess 301 redirect doesnt work

HTACCESS for 301 redirect:

 RewriteEngine on
 Redirect 301 /page.asp?DH=35 http://www.domain.ch/karriere

HTACCESS Code (later in the htaccess-File) for geting infos about the permalinks

 <IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteBase /

 <FilesMatch "\.(htm|php|js|css|htc|png|gif|jpe?g|ico|xml|csv|txt|swf|flv|eot|woff|svg|ttf|pdf|gz)$">
RewriteEngine Off
</FilesMatch>

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?catslugs=$0 [QSA,L]

</IfModule>

Unfortunately the 301-Redirekt doesnt work. What ist wrong, any tips?

thanks

Upvotes: 1

Views: 81

Answers (1)

anubhava
anubhava

Reputation: 784898

QUERY_STRING cannot be matched using Redirect directive. You need to use RewriteCond in mod_rewrite. Have it this way:

RewriteEngine on
RewriteBase /

RewriteCond %{QUERY_STRING} (^|&)DH=35(&|$) [NC]
RewriteRule ^page\.asp$ http://www.domain.ch/karriere? [L,NC,R=301]

<FilesMatch "\.(htm|php|js|css|htc|png|gif|jpe?g|ico|xml|csv|txt|swf|flv|eot|woff|svg|ttf|pdf|gz)$">
RewriteEngine Off
</FilesMatch>


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?catslugs=$0 [QSA,L]

</IfModule>

Upvotes: 1

Related Questions