Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure routing in Apache? [closed]

How do I hide my .html files for example when I go to www.mysite.com it redirects to www.mysite.com/index.html but it hides the /\index.html so it stays as www.mysite.com but is actually www.mysite.com/index.html . I don't really know how to explain but if you understand me can you please help, thanks.

like image 383
meme Avatar asked Oct 04 '16 10:10

meme


2 Answers

An .htaccess file is a simple ASCII file that you create with a text editor like Notepad or TextMate. It provides a way to make configuration changes on a per-directory basis.

RewriteRule ^([^\.]+)$ $1.html [NC,L]

Source - How to remove .php, .html, .htm extensions with .htaccess

like image 145
Shannon Young Avatar answered Sep 22 '22 12:09

Shannon Young


Please write below code in your .htaccess file.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*)\.html$ $1 [R=301,L]

The .html will be removed from your URL using above code. Lets say your contact us page URL is www.mysite.com/contact.html so using above code it will be www.mysite.com/contact instead.

like image 35
Rahul Patel Avatar answered Sep 20 '22 12:09

Rahul Patel