Forum Moderators: phranque
ErrorDocument 404 /index.php?action=p404
#
Order deny,allow
<Files .htaccess>
Deny from all
</Files>
#
Options +FollowSymlinks -Indexes
#
RewriteEngine on
RewriteBase /
#
# Externally redirect direct client requests for itemout.php to
# non-existent filepath to force 404-Not Found response
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /itemout\.php(\?[^\ ]*)?\ HTTP/
RewriteRule ^itemout\.php$ /filepath-that-is-known-not-to-exist.xyz [L]
#
# Externally redirect direct client requests for /mobile subdirectory
# to non-existent filepath to force 404-Not Found response
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /mobile/[^\ ]*\ HTTP/
RewriteRule ^mobile/ /filepath-that-is-known-not-to-exist.xyz [L]
#
# Externally redirect non-blank non-canonical mobile hostname requests to canonical mobile.example.com
# hostname. (Also accept and handle requests for the very-common mobile hostname hostname "m.example.com"
# as well as "www.m.example.com", "m.www.example.com", etc.)
RewriteCond %{HTTP_HOST} ^([^.]+\.)*(mobile|mobi|m)\. [NC]
RewriteCond %{HTTP_HOST} !^mobile\.example\.com$
RewriteRule ^(.*)$ http://mobile.example.com/$1 [R=301,L]
#
# Externally redirect non-blank non-mobile non-canonical hostname requests to canonical example.com hostname
RewriteCond %{HTTP_HOST} !^((mobile\.)?example\.com)?$
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
#
# Internally rewrite mobile subdomain requests to /mobile subdirectory unless already done
RewriteCond %{HTTP_HOST} ^mobile\.example\.com$
RewriteCond $1 !^mobile/
RewriteRule ^(.*)$ /mobile/$1 [L]
#
# Internally rewrite main site /media/ requests to itemout.php script
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^media/([^/.]*)/([A-Za-z0-9\-]+)\.html$ itemout.php?id=$1 [L]