Forum Moderators: phranque
Posting my .htaccess file:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?%{QUERY_STRING}&resource=$1 [L]
Any help would be appreciated.
You can associate "/" with "/index.php" using DirectoryIndex, canonicalize /index.php to "/" and force the canonical "www" subdomain by adding two redirect rules, and make your existing rewrite rule more efficient by using the [QSA] flag to append your additional query parameters to any requested query instead of "doing it manually":
DirectoryIndex index.php
#
RewriteEngine on
#
# Externally redirect direct client "/index.php" requests to canonical "/" URL in same subdirectory
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]*/)*index\.php(#[^?]*)?(\?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.php$ http://www.example.com/$1 [R=301,L]
#
# Externally redirect non-canonical hostname requests to canonical domain
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
# Internally rewrite all requests which do not resolve to existing files to /index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?resource=$1 [QSA,L]
Jim
RewriteCond $1 !(\.gif¦\.jpe?g¦\.png¦\.ico¦\.css¦\.js¦sitemap\.xml¦^robots\.txt¦^labels\.rdf¦^w3c/p3p\.xml)$
Replace the broken pipe "¦" characters with solid pipes before use; Posting on this forum modifies the pipe characters.
Jim
I use the term "true HTTP/1.0 clients" to distinguish them from clients that actually do support some or all ot the HTTP/1.1 protocol extensions and that do send a "Host:" request header, but that continue to 'publish' as HTTP/1.0 clients for compatibility reasons. For example, some versions of Googlebot do this.
It's OK to use "=www.example.com" for an exact positive match, but using it for a negative match would require a second RewriteCond to prevent the HTTP/1.0 looping problem.
Jim