Skip to content

Instantly share code, notes, and snippets.

@davidvandenbor
Created July 8, 2014 12:48
Show Gist options
  • Select an option

  • Save davidvandenbor/631229eee68aace98917 to your computer and use it in GitHub Desktop.

Select an option

Save davidvandenbor/631229eee68aace98917 to your computer and use it in GitHub Desktop.
Handy .htaccess entries
# hide index.php from the domain URL
# for WordPress users: Permalink URL canonicalization is automated via PHP in WordPress 2.3+
RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# parked domains permanent 301 redirect so search engines not to treat them as duplicate content.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.maindomain.com$
RewriteRule ^(.*)$ http://www.maindomain.com/$1 [R=301]
# force only the www version of your web site, to make your_domain.com redirect to www.your_domain.com
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.your_domain.com$
RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment