开发者

HTACCESS and redirect 301

开发者 https://www.devze.com 2023-04-12 17:33 出处:网络
I want to make a redirect 301 via htaccess but for some reason it\'s doesn\'t works because I have more rules in htaccess, but if I remove them and leaves just the redirect it\'s works.

I want to make a redirect 301 via htaccess but for some reason it's doesn't works because I have more rules in htaccess, but if I remove them and leaves just the redirect it's works.

any idea?..

Options +FollowSymLinks
RewriteEngine On

ErrorDocum开发者_运维知识库ent 404 error.php
RewriteRule ^sitemap.xml sitemap.php

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} ^(.*)$
RewriteRule (.*) seoPage.php?w=%{REQUEST_URI}


Put the redirect to the first place.

In htaccess the first matching rule workes.
So, there may be another rule overwriting this one.


It does not seems to me you are doing 301 in whole document. 301 should look like this

RewriteCond %{REQUEST_URI} ^(.*)$
RewriteRule (.*) seoPage.php?w=%{REQUEST_URI} [L,R=301]

With emphasis on R=301 . Check this page. There in detail described what each part of rewriting rule mean. Alternatively you can check documentation for .htaccess files.

Also lvil has a good point.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号