Home > Back-end >  Rewrite rule without folders and without file extension
Rewrite rule without folders and without file extension

Time:05-09

I would like to set a 301 redirect from this :
https://www.mydomain.tld/fr/amp/category/mypage.amphtml
to this :
https://www.mydomain.tld/mypage

For other countries i want to keep language so redirect from this :
https://www.mydomain.tld/en/amp/category/mypage.amphtml
to this :
https://www.mydomain.tld/en/mypage

For now i have these rules for first part :

RewriteCond %{REQUEST_URI} ^fr/amp/category/(.*)$
RewriteRule ^(.*).amphtml$ /$1
RewriteRule ^fr/amp/category/(.*) /$1 [R=301,L]

But i have the thing don't work as expected. And i get this result : https://www.mydomain.tld/mypage.html

Some help or advices ?

CodePudding user response:

Finally i used these simple rules :

RewriteRule ^fr/amp/category/(.*).amphtml$ https://www.mydomain.tld/$1 [R=301,L]  
RewriteRule ^en/amp/category/(.*).amphtml$ https://www.mydomain.tld/en/$1 [R=301,L]  
  • Related