I'trying to write a regex that matches an url with and without html, Itried this way but ots not working
RedirectMatch 301 ^/my_url(\.html)$ /es/promo/my_url.html
It shoul work for myurl
and my_url.html
but it doesn't
I'trying to write a regex that matches an url with and without html, Itried this way but ots not working
RedirectMatch 301 ^/my_url(\.html)$ /es/promo/my_url.html
It shoul work for myurl
and my_url.html
but it doesn't
Could you please try following, written and tested as per shown samples. This will rewrite every non existing file and non existing directory to respective html in backend to be served. Please make sure you clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/my_url [NC]
RewriteRule ^(.*)/?$ $1.html [L]
You may try these rules in your site root .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/es/promo/ [NC]
RewriteRule ^(.*?)(?:\.html?|/?)$ /es/promo/$1.html [L,NC,R=301]