最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

htaccess Redirect 301 doesn't work. How to debug?

programmeradmin3浏览0评论

I transfer an old site to wordpress.

The problem is that there are a few links in the web, that are from the old page and need to be transferred to new slugs.

Since I don't want to fill in more plugins to the site just for simple static redirects, I added lines like the following to the < IfModule mod_rewrite.c > section in .htaccess

# END W3TC Browser Cache
# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=W3TC_ENC:_gzip]
RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
RewriteRule .* - [E=W3TC_PREVIEW:_preview]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} =""
RewriteCond %{REQUEST_URI} \/$
RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]


# My redirects begin here

Redirect 301 /?page=123 /team/
Redirect 301 /?page=456 /contact/
# ... ect

However when I try

curl -I www.example/?page=123

I get 404 not 301. Also www.example/team/ gives 200.

How can I debug my redirects? Are Redirect 301 in some way affected by the RewriteCond and RewriteRule set that's been added by Wordpress or plugins?

I transfer an old site to wordpress.

The problem is that there are a few links in the web, that are from the old page and need to be transferred to new slugs.

Since I don't want to fill in more plugins to the site just for simple static redirects, I added lines like the following to the < IfModule mod_rewrite.c > section in .htaccess

# END W3TC Browser Cache
# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=W3TC_ENC:_gzip]
RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
RewriteRule .* - [E=W3TC_PREVIEW:_preview]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} =""
RewriteCond %{REQUEST_URI} \/$
RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]


# My redirects begin here

Redirect 301 /?page=123 /team/
Redirect 301 /?page=456 /contact/
# ... ect

However when I try

curl -I www.example/?page=123

I get 404 not 301. Also www.example/team/ gives 200.

How can I debug my redirects? Are Redirect 301 in some way affected by the RewriteCond and RewriteRule set that's been added by Wordpress or plugins?

Share Improve this question asked Aug 14, 2019 at 11:57 user6329530user6329530 1651 gold badge1 silver badge6 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Please check with this site for 301 or 302 redirections

http://www.redirect-checker/

发布评论

评论列表(0)

  1. 暂无评论