Mobile Redirect using htaccess

Tim Stone’s solution is on the right track, but his initial rewriterule and and his cookie name in the final condition are different, and you can not write and read a cookie in the same request. Here is the finalized working code: RewriteEngine on RewriteBase / # Check if this is the noredirect query string … Read more

How to remove .html from URL?

I think some explanation of Jon’s answer would be constructive. The following: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d checks that if the specified file or directory respectively doesn’t exist, then the rewrite rule proceeds: RewriteRule ^(.*)\.html$ /$1 [L,R=301] But what does that mean? It uses regex (regular expressions). Here is a little something I made … Read more

How to redirect all HTTP requests to HTTPS

The Apache docs recommend against using a rewrite: To redirect http URLs to https, do the following: <VirtualHost *:80> ServerName www.example.com Redirect / https://www.example.com/ </VirtualHost> <VirtualHost *:443> ServerName www.example.com # … SSL configuration goes here </VirtualHost> This snippet should go into main server configuration file, not into .htaccess as asked in the question. This article … Read more