Skip to content

Instantly share code, notes, and snippets.

@drewjoh
Created April 14, 2010 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drewjoh/365507 to your computer and use it in GitHub Desktop.
Save drewjoh/365507 to your computer and use it in GitHub Desktop.
# CodeIgniter writing
RewriteCond $1 !^(index\.php|images|robots\.txt|css|user_files|subdomain1|subdomain2)
RewriteRule ^(.*)$ /index.php/$1 [L]
# Redirect adding leading www to root domain if no subdomain is specified
RewriteCond %{HTTP_HOST} !^(subdomain1|subdomain2|www)\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
# Redirect deleting leading www to root domain if no specified subdomain is used
RewriteCond %{HTTP_HOST} !^(subdomain1|subdomain2)\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment