Piyush
Piyush

Reputation: 1

htaccess file not working

I have an .htaccess file with the following code:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_URI} (/|\.html|/[^.]*)$ [NC]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^([A-Za-z0-9-_]+)/?$ $1.html [NC]
</IfModule>

But it is not working. I want to change the URL, e.g., www.example.com/about.html to www.example.com/about and so on.

Upvotes: 0

Views: 150

Answers (1)

Juan Cort&#233;s
Juan Cort&#233;s

Reputation: 21062

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

Keep this in your .htaccess snippets file if you don't understand it for the next time. Replace .html with the file extension you need to remove.

Upvotes: 3

Related Questions