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

by user6329530   Last Updated August 14, 2019 12:08 PM

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.com/?page=123

I get 404 not 301. Also www.example.com/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?

Tags : redirect


Answers 1


Please check with this site for 301 or 302 redirections

http://www.redirect-checker.org/

Wordpress Dev
Wordpress Dev
August 14, 2019 12:01 PM

Related Questions



Custom URL redirect in WP

Updated September 04, 2018 23:08 PM


Redirect users in first login to a dynamic link

Updated May 25, 2017 02:08 AM