Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Dynamické subdomény pomocí .htaccess
### Source code moved to https://github.com/janpecha/htaccess-subdomains/ ###
## Custom Error Pages
#ErrorDocument 404 /errors/e404.html
<IfModule mod_dir.c>
DirectorySlash Off
</IfModule>
Options -Indexes
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
## Custom Error Pages
#RewriteCond %{REQUEST_URI} ^/my-error-page\.html$ [OR]
#RewriteCond %{REQUEST_URI} ^/errors/e404\.html$
#RewriteRule ^ - [L]
# presmerovani subdomeny s www na verzi bez www
RewriteCond %{HTTP_HOST} www\.(.*)\.([^\.]+)\.([^\.]*)$
RewriteRule (.*)$ http://%1.%2.%3/$1 [R=301,L,NE]
# presmerovani domeny 2. radu na verzi s www
RewriteCond %{HTTP_HOST} ^([^\.]+)\.([^\.]*)$
RewriteRule (.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L,NE]
# ochrana proti zacyklení
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
#kontrola existence subdomeny
RewriteCond %{HTTP_HOST} ^(.*)\.([^\.]*)\.([^\.]*)$
RewriteCond %{DOCUMENT_ROOT}/%1_root !-d
RewriteRule ^ - [R=404,NC,L]
# presmerovani na verzi s lomitkem
RewriteCond %{HTTP_HOST} ^(.*)\.([^\.]*)\.([^\.]*)$
RewriteCond %{DOCUMENT_ROOT}/%1_root/%{REQUEST_URI}/ -d
RewriteRule ^(.*)[^/]$ %{REQUEST_URI}/ [R=301,L,NE]
# podstrceni obsahu
RewriteCond %{HTTP_HOST} ^(.*)\.([^\.]*)\.([^\.]*)$
RewriteRule ^(.*)$ %1_root/$1 [L]
</IfModule>
@janpecha

This comment has been minimized.

Show comment
Hide comment
@janpecha

janpecha Jul 2, 2013

Source code moved to GitHub repository - https://github.com/janpecha/htaccess-subdomains/

Owner

janpecha commented Jul 2, 2013

Source code moved to GitHub repository - https://github.com/janpecha/htaccess-subdomains/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment