admin管理员组

文章数量:1277896

My wordpress use custom permalinks url with rules /%postname%.html

And Htaccess rules

# This file was updated by Duplicator Pro on 2021-11-02 05:53:04.

# BEGIN WordPress
<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
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

So my post url looks like this (with amp plugin)

.html <--- original url

.html/amp <--- amp url

.html/amp/ <--- amp url

.html?amp <--- amp url

.html?amp=1 <--- amp url

I have disabled amp plugin recently , this leave me with thousand not found url from previous amp url ..and i used solution provided on this answer

so my htaccess looks like this

# This file was updated by Duplicator Pro on 2021-11-02 05:53:04.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} (.+)/amp(.*)$
RewriteRule ^ %1/ [R=301,L]
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
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

But then i moved from shared hosting to vps (centos 7) ..using the same rules, now it add additional slash in url .html/ where it should be .html

Request 
> GET /post.html/amp/ HTTP/1.1
> Host: www.host
> User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246
Response 
< HTTP/1.1 301 Moved Permanently
< Date: Thu, 04 Nov 2021 07:43:16 GMT
< Content-Type: text/html; charset=iso-8859-1
< Content-Length: 274
< Connection: keep-alive
< location: .html/
< cache-control: max-age=0
< expires: Thu, 04 Nov 2021 07:43:16 GMT
< CF-Cache-Status: DYNAMIC
< Server: cloudflare

my apology if i post to long question, but i need help to redirect /amp /amp/ ?amp ?amp=1 ?amp=0 to original non amp url

Thank you

本文标签: redirectRedirecting amp url to non amp url