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:


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
# SGS XMLRPC Disable Service END

<IfModule mod_rewrite.c>
Redirect 301 /ads.txt https://srv.adstxtmanager.com/5075/angolodiwindows.com
# 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]

# 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]

# END WordPress
<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"

# 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?

  • It doesn't look like that AMP URL would be affected by your .html redirect rule. There is no .html in that URL. May 17 at 9:41
  • Yes, but it seems strange to me that since I made the change I have this mistake, don't you think? I can't understand what the cause is, they are meaningless pages
    – Elvis
    May 17 at 13:14
  • It looks like coincidence to me, I don't see how one could possibly have anything to do with the other. What is the full error message that GSC reports for that amp URL? Where does GSC say that it found the link to it if you inspect it? What status does that URL return if you test it against your server yourself? Do you use accelerated mobile pages (AMP) at all? May 17 at 13:35
  • i have something like 5406 url interested for this error and seems so much. If i inspect one url i see "redirect problem" and the url are so similar. However if i open the url i can see the page correctly without error or redirect if i analyze the page here i see code 200 wheregoes.com/trace/20222642666
    – Elvis
    May 17 at 13:59
  • The redirect from that encoding the / 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. May 17 at 15:00


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.