Jump to main navigation

Category: .htaccess

Removing index.html with mod_rewrite in .htaccess

It's quite easy to remove index.html from a URL with mod_rewrite. Let's say we want to redirect www.dense13.com/index.html to www.dense13.com:

RewriteEngine On
RewriteRule ^index\.html$ / [R=301,L]

Here's a brief explanation, if you're not familiar with .htaccess syntax: Read the full text...

mod_rewrite changes url to lower-case in Windows

Using mod_rewrite to ensure canonical URL's in my CMS, I run across a strange behavior (bug?) of mod_rewrite. It seems that in Windows and under certain circumstances, it changes the case of the URL to lowercase. While this normally won't be a problem (Windows URL's are case insensitive) it can have undesirable effects if you need process the URL with PHP, for example. Read the full text...

Redirecting non-www to www with .htaccess

If you want to redirect all non-www requests to your site to the www version, all you need to do is add the following code to your .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

This will redirect any requests to http://my-domain.com to http://www.my-domain.com. There are several benefits from doing that: Read the full text...

Additional content and navigation


Main navigation menu