Verizon cell phones

Modx htaccess

This article will look at the .htaccess file for ModX CMS websites. I've taken the sample htaccess file shipped with the ModX 1.03 release and commented it for better understanding.




#----------------------------------------------
# Custom htaccess for ModX
#
# May 21, 2010
# Kerry Kobashi
#----------------------------------------------

#----------------------------------------------------------
# We turn on symbolic links here as this is a requirement according
# to the Apache documentation (see Per-directory Rewrites section):
# http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
#
# However...
# On shared hosting environments its best not to use FollowSymlinks
# and use SymLinksIfOwnerMatch
# http://onlamp.com/pub/a/apache/2004/02/19/apache_ckbk.html
# in which case you would:
# Options -FollowSymlinks +SymLinksIfOwnerMatch
#----------------------------------------------------------
Options -FollowSymlinks +SymLinksIfOwnerMatch

#-------------------------------------------------------------------
# Turn modrewrite on and set rewrite base to assume var/www or
# /htdocs contains a modx file structure like
# apache/htdocs/sitename
# assets
# install
# manager
#
# In this case RewriteBase is the root
#
# If the file structure is
# apache/htdocs/sitename
# modx
# assets
# install
# manager
#
# Then rewritebase should be
# RewriteBase /modx
#-------------------------------------------------------------------
RewriteEngine On
RewriteBase /

#-------------------------------------------------------------------------
# Fix Apache internal dummy connections from breaking [(site_url)] cache
#-------------------------------------------------------------------------
RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
RewriteRule .* - [F,L]

#-------------------------------------------------------------------------
# This is to solve canonical url issues
# If user agent requests site.com/etc (without www)
# then we 301 to http://www.site.com/etc
#-------------------------------------------------------------------------
RewriteCond %{HTTP_HOST} !^www\.isite.com$ [NC]
RewriteRule (.*) http://www.isite.com/$1 [R=301,L]

#---------------------------------------------------------------------------------
# Don't rewrite manager directory, assets directory requests
# Also don't rewrite image requests
# The effect here is that all rewriting processing stops and doesn't continue [L]
# onto the main router index.php below
#---------------------------------------------------------------------------------
RewriteRule ^(manager|assets)/*$ - [L]
RewriteRule \.(jpg|jpeg|png|gif|ico)$ - [L]

#--------------------------------------------------------------
# If the file or directory doesn't exist go to the main router
#--------------------------------------------------------------
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Filed under: