Skip to content

Instantly share code, notes, and snippets.

@hm2k
Created May 28, 2009 14:11
Show Gist options
  • Save hm2k/119325 to your computer and use it in GitHub Desktop.
Save hm2k/119325 to your computer and use it in GitHub Desktop.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/folder
RewriteRule !\.(js|ico|gif|jpg|png|css)$ /folder/index.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/folder2
RewriteRule !\.(js|ico|gif|jpg|png|css)$ /folder2/index.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/folder3
RewriteRule !\.(js|ico|gif|jpg|png|css)$ /folder3/index.php [NC,L]
???
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(folder|myfolder|yourfolder)
RewriteRule !\.(js|ico|gif|jpg|png|css)$ /$1/index.php [NC,L]
#From http://www.hm2k.com/posts/creating-subdomains-from-directories-using-mod_rewrite-in-apache-htaccess
#Grab the subdomain from the domain
RewriteCond %{HTTP_HOST} ^([^.]+).hm2k.org$
#Make sure the subdomain is not www or example
RewriteCond %{1} !^(www|example)$
#Check if the directory actually exists before we go there
RewriteCond /home/hm2k/public_html/%1 -d
#This stops it from looping
RewriteCond %{REQUEST_FILENAME} !^/home/hm2k/public_html/
#Finally, this is the actual rewrite
RewriteRule (.*) /home/hm2k/public_html/%1/$1 [Last]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment