In the last year, my website has had a problem with many 404 errors where .html
was added to URLs that shouldn't have it. To resolve this problem I modified the HTACCESS with this line:
RewriteEngine On
RewriteRule ^(.*)\.html$ /$1 [L,R=301]
#301 from example.com/page.html to example.com/page
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
but after this addition, I've see more errors in search console. Many of them are redirect errors with this type of URL:
.../tag/windows-10/page/2/?amp%25252525252525252525252525252525252525252525252525252525252525252525252525252Fpage%25252525252525252525252525252525252525252525252525252525252525252525252525252F6%2525252525252525252525252525252525252525252525252525252525252525252525252Famp%2525252525252525252525252525252525252525252525252525252525252525252525252F%25252525252525252525252525252525252525252525252525252525252525252525252Famp%25252525252525252525252525252525252525252525252525252525252525252525252F%252525252525252525252525252525252525252525252525252525252525252Famp%252525252525252525252525252525252525252525252525252525252525252F%2525252525252525252525252525252525252525252525252525252525252Famp%2525252525252525252525252525252525252525252525252525252525252F%25252525252525252525252525252525252525252525252525252Famp%25252525252525252525252525252525252525252525252525252F%252525252525252525252525252525252525252525252525252Famp%252525252525252525252525252525252525252525252525252F%2525252525252525252525252525252525252525252525252Famp%2525252525252525252525252525252525252525252525252F%25252525252525252525252525252525252525252525252Famp%25252525252525252525252525252525252525252525252F%25252525252525252525252525252525252525252Famp%25252525252525252525252525252525252525252F%25252525252525252525252525252525252Famp%25252525252525252525252525252525252F%252525252525252525252525252525252Famp%252525252525252525252525252525252F%2525252525252525252525252Famp%2525252525252525252525252F%2525252525252525252Famp%2525252525252525252F%25252525252525252Famp%25252525252525252F%25252525252Famp%25252525252F%252525252Famp%252525252F%2Famp%2F/amp//amp/
My full .htaccess file is:
RewriteEngine On
RewriteRule ^(.*)\.html$ /$1 [L,R=301]
# SGS XMLRPC Disable Service
<Files xmlrpc.php>
order deny,allow
deny from all
</Files>
# SGS XMLRPC Disable Service END
#BEGIN_ADSTXTMANAGER_HTACCESS_HANDLER
<IfModule mod_rewrite.c>
Redirect 301 /ads.txt https://srv.adstxtmanager.com/5075/angolodiwindows.com
</IfModule>
#END_ADSTXTMANAGER_HTACCESS_HANDLER
# HTTPS forced by SG-Optimizer
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
# END HTTPS
# BEGIN WordPress
# Le direttive (linee) tra `BEGIN WordPress` e `END WordPress` sono
# generate dinamicamente, e dovrebbero essere modificate solo tramite i filtri di WordPress.
# Ogni modifica alle direttive tra questi marcatori verrà sovrascritta.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# AMPFORWPLBROWSERCSTART Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg
ExpiresByType application/vnd.ms-fontobject "access 1 year"
ExpiresByType application/x-font-ttf "access 1 year"
ExpiresByType application/x-font-opentype "access 1 year"
ExpiresByType application/x-font-woff "access 1 year"
ExpiresByType image/svg+xml "access 1 year"
ExpiresByType image/webp "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType text/css "access 3 month"
ExpiresByType text/javascript "access 3 month"
ExpiresByType text/html "access 3 month"
ExpiresByType application/javascript "access 3 month"
ExpiresByType application/x-javascript "access 3 month"
ExpiresByType application/xhtml-xml "access 3 month"
ExpiresByType application/pdf "access 3 month"
ExpiresByType application/x-shockwave-flash "access 3 month"
ExpiresDefault "access 3 month"
</IfModule>
# END Caching AMPFORWPLBROWSERCEND
# SGO Unset Vary
Header unset Vary
# SGO Unset Vary END
RewriteEngine On
RewriteRule .* - [E=Cache-Control:no-cache]
#301 from example.com/page.html to example.com/page
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/|amp/).* [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ ///.*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
What's wrong? What can I modify to avoid a redirect of the amp pages?
.html
redirect rule. There is no.html
in that URL./
in the query string with%2F
. Do you have any rewrite rules that may be doing that explicitly? If not, it may be some rule that doesn't have the[NE]
(no escape) flag, or built in Apache behavior, I'm not really sure. In any case, I still am waiting for you to answer the question of whether you use AMP or not on your site.