-
RULE_0_START:
-
# Get the document root path and put value into the SCRATCH array.
-
# This is the server path not the web URL.
-
# e.g. /content/DesignerPlus/i/n/domain.co.uk/web/
-
map path into SCRATCH:DOCROOT from /
-
-
# Get the URL without the domain.
-
# e.g. /test&colour=red
-
# e.g. /blog/2007/10/31/an-example-post/?color=red
-
set SCRATCH:ORIG_URL = %{URL}
-
set SCRATCH:REQUEST_URI = %{URL}
-
-
# See if there are any queries in our URL.
-
match URL into $ with ^(.*)\?(.*)$
-
# If there are...
-
if matched then
-
# Set a var to path without the domain part.
-
# e.g. /blog/2007/10/31/an-example-post
-
set SCRATCH:REQUEST_URI = $1
-
# Set a var to the passed queries.
-
# e.g. colour=red
-
set SCRATCH:QUERY_STRING = $2
-
endif
-
RULE_0_END:
-
-
RULE_1_START:
-
# This is setting a var to the server path and sub folders.
-
# e.g. /content/DesignerPlus/i/n/domain.co.uk/web//blog/2007/10/31/an-example-post
-
set SCRATCH:REQUEST_FILENAME = %{SCRATCH:DOCROOT}
-
set SCRATCH:REQUEST_FILENAME . %{SCRATCH:REQUEST_URI}
-
-
# Check to see if the file exists.
-
look for file at %{SCRATCH:REQUEST_FILENAME}
-
if not exists then
-
# The file wasn't found so is it a folder?
-
look for dir at %{SCRATCH:REQUEST_FILENAME}
-
if not exists then
-
# No folder either. So now check the URL for special hosting folders.
-
match SCRATCH:ORIG_URL into % with ^/webmail|^/tech_support|^/controlpanel
-
if matched then
-
# If a special folder was requested end the script.
-
goto END
-
else
-
# There were no files, folders or special folders so set the new URL.
-
-
# -- Sub directory -------------------------------------------------------------
-
# If the blog is in a sub directory...
-
# e.g. /blog/index.php/2007/10/31/an-example-post
-
match SCRATCH:REQUEST_URI into $ with ^/blog(.*)
-
if matched then
-
set URL = /blog/index.php$1
-
endif
-
# -- Sub directory ends --------------------------------------------------------
-
-
# or...
-
-
# -- Top level -----------------------------------------------------------------
-
# If the blog is in the top level of the site...
-
# e.g. /index.php/2007/10/31/an-example-post
-
# set URL = /index.php%{SCRATCH:REQUEST_URI}
-
# -- Top level ends ------------------------------------------------------------
-
-
# Go to the next rule.
-
goto RULE_2_START
-
endif
-
endif
-
endif
-
# If files or folders were found end the rewrite script.
-
goto END
-
RULE_1_END:
-
-
RULE_2_START:
-
# Check for queries in the requested URL.
-
match SCRATCH:ORIG_URL into % with \?(.*)$
-
if matched then
-
# If queries were found add them to the new URL.
-
# e.g. /index.php/2007/10/31/an-example-post/&colour=red
-
set URL = %{URL}&%{SCRATCH:QUERY_STRING}
-
endif
-
-
# -- Sub directory -------------------------------------------------------------
-
# If you only want to rewrite the sub directory uncomment this bit.
-
match SCRATCH:ORIG_URL into % with ^/blog
-
if matched then
-
# -- Sub directory ends --------------------------------------------------------
-
-
# End the script.
-
goto END
-
-
# -- Sub directory -------------------------------------------------------------
-
endif
-
# -- Sub directory ends --------------------------------------------------------
-
RULE_2_END: