0

I want to redirect all my old pages (mywebsite.com/help.html) to (mywebsite.com/help).

So I just added this code in my .htaccess file:

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{4,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R,L,NC]

it's working but I get a strange issue when I try this URL:

mywebsite.com/page.html

I get this result

www.http//mywebsite.com/page/

You can see URL rewrite adding this invalid code in the start of the page url (((www.http//))

Joe
  • 4,877
  • 5
  • 30
  • 51

1 Answers1

0

Try this one:

RewriteCond %{REQUEST_FILENAME}.html -f  
RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [L]

Took from How to hide the .html extension with Apache mod_rewrite

whites11
  • 12,008
  • 3
  • 36
  • 53