Skip to content

Instantly share code, notes, and snippets.

@thetasnippets
Created October 5, 2013 16:39
Show Gist options
  • Save thetasnippets/6843102 to your computer and use it in GitHub Desktop.
Save thetasnippets/6843102 to your computer and use it in GitHub Desktop.
apache: htaccess recipes
# 301 redirect one domain to another
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)$ http://www.__DOMAIN.what__/$1 [R=301]
# Nice URLS PHP .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L,QSA]
# http://domain/about -> http://domain/about.php
# Redirect index.php Requests
# ——————————
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{THE_REQUEST} !/system/.*
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L]
RewriteCond %{THE_REQUEST} ^GET
# Specific custom URLs
RewriteEngine on
RewriteRule ^foo/$ /pages/foo.html [L]
RewriteRule ^bar/$ /bar.php [L]
RewriteRule ^qux/$ /qux.html [L]
RewriteRule ^quux/$ /pages/quux.htm [L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment