Hi, I am designing a website in HTML and my files have an extension .html, is there a way to remove that from the links? I mean, currently I have to type http://www.mysite.com/page1.html http://www.mysite.com/page2.html But, I see some sites such as http://www.mysite.com/page1/ http://www.mysite.com/page2/ How can I do that?
Read this... http://eisabainyo.net/weblog/2007/08/19/removing-file-extension-via-htaccess/ Code (markup): its about removing file extensions via .htaccess
UPDATE: I tried the code and it worked. I will post the code here as well, since that blog post might be removed in the future. This will remove file extensions like .html, .php, .asp and so on. RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(.*)$ $1.html # Replace html with your file extension, eg: php, htm, asp Code (markup): This one will add a trailing slash to the end, like website.com/home/ RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^([^/]+)/$ $1.html # Forces a trailing slash to be added RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ RewriteRule (.*)$ /$1/ [R=301,L] Code (markup):
wow, I didn't knew like this existed! i thought that ( site.com/page/ ) can only be done in php/asp I will check this on my site too!! ++Rep