Y
Y
Ysery2018-12-03 23:41:37
htaccess
Ysery, 2018-12-03 23:41:37

Remove everything in the request after ***.html excluding /amp/ via htaccess, how to do it?

I found this code for cutting off all characters after .html in the link

RewriteEngine On
RewriteRule (.+?)\.html.+$ https://%{HTTP_HOST}/$1.html [L,R=301]

It does what it needs to do without affecting links like ...***.html?123 which is great. But there are more links on the site ...***.html/amp/
What should be the htaccess code to exclude clipping in the presence of /amp/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2018-12-04
@dodo512

RewriteRule ^(.+?)\.html(?!/amp/).+$ https://%{HTTP_HOST}/$1.html [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question