16-03-2010

Subdirectories and URL rewriting

When we install CMS-systems, we always create them in a seperate subfolder on the webspace. This to keep things clear, and logically structured.
However the problem that then occurs is that URLs tend to get ugly.
E.g. our webspace looks like: http://www.agito.be/CMS/index.php, instead of http://www.agito.be/index.php

.htaccess files are an ideal solution, but often difficult to use. Today I managed to remove the /CMS/ part out of the URL without side-effects. Here is the code:

RewriteEngine on
#
# Internally rewrite requests for all pages in "/" to pages in /CMS/
#
# If not already rewritten to /CMS/
RewriteCond $1 !^CMS/
# Prepend "/CMS" to the requested URL-path
RewriteRule (.*) /CMS/$1 [L]

If CMSMS would remove the index.php to be shown, I would be completely happy :)

Geen opmerkingen: