Skip to content

Instantly share code, notes, and snippets.

@Shaz3e
Created February 22, 2014 15:30
Show Gist options
  • Save Shaz3e/9156636 to your computer and use it in GitHub Desktop.
Save Shaz3e/9156636 to your computer and use it in GitHub Desktop.
# .htaccess - www -> http:// - http:// -> www - nice URLs
Options -Indexes
Options +FollowSymLinks
RewriteBase /
RewriteEngine On
## /id/product-name/ to index.php?id=id
RewriteRule ^([0-9]*)/(.*)$ index.php?id=$1 [L]
## non www to wwww ##
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.site\.com [NC]
RewriteRule (.*) http://www.site.com/$1 [R=301,L]
## www to non www ##
RewriteCond %{HTTP_HOST} !^site\.com$
RewriteRule (.*) http://site.com/$1 [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment