Forum Moderators: phranque
/
/site/ # this directory gets rsynced
/site/about/ # actual page is index.html; DirectoryIndex correctly hides it
/site/sample-page/
/site/blog/2010/01/01/some-post/
/other/
/folders/
/on/
/the/
/server/ RewriteEngine On
# Map http://www.example.com to /site.
RewriteRule ^$ /site/ [L]
# Map http://www.example.com/x to /site/x unless there is a x in the web root.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/site/
RewriteRule ^(.*)$ /site/$1
# Add trailing slash to directories without them so DirectoryIndex works.
# This does not expose the internal URL.
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME} !/$
RewriteRule ^(.*)$ $1/
# Disable auto-adding slashes to directories without them, since this happens
# after mod_rewrite and exposes the rewritten internal URL, e.g. turning
# http://www.example.com/about into http://www.example.com/site/about
DirectorySlash off RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME} !/$
RewriteRule ^(.*)$ $1/
RewriteEngine On
#
# Externally redirect to add missing trailing slashes to directory requests
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*[^/])$ http://www.example.com/$1/ [R=301,L]
#
# Map http://www.example.com/ to /site/ subdirectory
RewriteRule ^$ /site/ [L]
#
# Map http://www.example.com/x to /site/x unless there is a x in the web root.
RewriteCond $1 !^site/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /site/$1 [L]
RewriteEngine On
# Map http://www.example.com to /site.
RewriteRule ^$ /site/ [L]
# Map http://www.example.com/x to /site/x unless there is a x in the web root.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/site/
RewriteRule ^(.*)$ /site/$1
# Add trailing slash to directories within /site
# This does not expose the internal URL.
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule ^site/(.*[^/])$ http://www.example.com/$1/ [R=301]