Forum Moderators: phranque
RewriteEngine On
RewriteBase /
RewriteRule^([a-z0-9-]+)/?([a-z0-9-]+)?/?([a-z0-9-]+)?/?$ index.php?x=$1&y=$2&z=$3 [L]
/projects/?x=projects&y=&z=
/projects/test/?x=projects&y=test&z=
/projects/test/again/?x=projects&y=test&z=again
Options +FollowSymLinks -MultiViews
RewriteEngine on
#
# Externally redirect to add missing trailing slash to search-friendly URLs
RewriteRule ^([a-z0-9\-](/[a-z0-9\-]){0,2})$ http://www.example.com/$1/ [R=301,L]
#
# Internally rewrite search-friendly URLs to script
RewriteRule ^([a-z0-9\-]+)/(([a-z0-9\-]+)/(([a-z0-9\-]+)/)?)?$ index.php?x=$1&y=$3&z=$5 [L]
Options +FollowSymLinks -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Change www. requests to plain requests
RewriteCond%{http_host} ^www\.example\.com [NC]
RewriteRule^(.*)$ http://example.com/$1 [R=301,NC]
# Image hotlink prevention
RewriteCond%{HTTP_REFERER} !^$
RewriteCond%{HTTP_REFERER} !^http(s)?://(www\.)?example.com [NC]
RewriteRule\.(jpg|jpeg|png|gif)$ http://example.com/hotlink.gif [NC,R,L]
# Shorten js and css packers
RewriteRule^js/?$ /application/packers/jspacker.php [L]
RewriteRule^css/ie(\d{1})$ /application/packers/csspacker.php?ie=$1 [L]
RewriteRule^css/?$ /application/packers/csspacker.php [L]
# Externally redirect to add missing trailing slash to search-friendly URLs
RewriteRule ^([a-z0-9\-](/[a-z0-9\-]){0,2})$ http://example.com/$1/ [R=301,L]
#
# Internally rewrite search-friendly URLs to script
RewriteRule ^([a-z0-9\-]+)/(([a-z0-9\-]+)/(([a-z0-9\-]+)/)?)?$ index.php?x=$1&y=$3&z=$5 [L]
</IfModule>
[edited by: jdMorgan at 10:14 pm (utc) on Feb 4, 2010]
[edit reason] example.com [/edit]
Options +FollowSymLinks -MultiViews
#
RewriteEngine on
#
# Externally redirect hotlinked image requests to replacement image
RewriteCond %{HTTP_REFERER} !^(https?://(www\.)?example.com)?$
RewriteCond %{REQUEST_URI} !^/no-hotlinking\.gif$
RewriteRule \.(jpe?g|gif|png)$ http://example.com/no-hotlinking.gif [NC,R=302,L]
#
# Externally redirect to add missing trailing slash to search-friendly URLs
RewriteRule ^([a-z0-9\-]+(/[a-z0-9\-]+){0,2})$ http://example.com/$1/ [R=301,L]
#
# Externally redirect all requests for non-canonical hostname to canonical hostname
RewriteCond %{HTTP_HOST} !^(example\.com)?$
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
#
# Internally rewrite search-friendly URLs to script
RewriteRule ^([a-z0-9\-]+)/(([a-z0-9\-]+)/(([a-z0-9\-]+)/)?)?$ index.php?x=$1&y=$3&z=$5 [L]
#
# Internally rewrite short js and css packer URL requests to actual filepaths
RewriteRule ^js/?$ /application/packers/jspacker.php [L]
RewriteRule ^css/ie([0-9])/?$ /application/packers/csspacker.php?ie=$1 [L]
RewriteRule ^css/?$ /application/packers/csspacker.php [L]
[edited by: jdMorgan at 3:52 pm (utc) on Feb 5, 2010]