mcanthony/moonstone/master/samples/.htaccess - Htaccess File

mcanthony/moonstone/master/samples/.htaccess

## Help our users by allowing them to write sample names and forward them to our Sample.html file.
# Parts of this excerpted from _ michael @
# http://www.zeilenwechsel.de/it/articles/8/Using-mod_rewrite-in-.htaccess-files-without-knowing-the-RewriteBase.html
<IfModule rewrite_module>
RewriteEngine on
RewriteBase /

# Store the current location in an environment variable CWD
RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)1$
RewriteRule ^.*$ - [E=CWD:%2]

# Requiesting a file that doesn't exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^index.html?$ %{ENV:CWD}Sample.html?All [NC,R,QSA,L]

# Requesting the current directory or a non-existant index.htm(l)
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME}index.html !-f
RewriteRule .* %{ENV:CWD}Sample.html?All [R,QSA,L]

# verify that we're only looking for files ending in htm(l) that don't exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} .html?$ [or]
RewriteCond %{REQUEST_FILENAME} !.

# Just by prefixing the environment variable, we can safely rewrite anything now
RewriteRule ([^/]+?)(.html)?$ %{ENV:CWD}Sample.html?$1 [R,L]
</IfModule>

On Github License

Files

Download PDF of Htaccess file
ENV, REQUEST_FILENAME, REQUEST_URI

Comments

Apache