Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- RewriteRules and .htaccess


mdsww - 12:50 am on Aug 19, 2011 (gmt 0)


Thank you for all of your recommendations and suggestions. I am starting to understand, but will just make sure I am on the right track.

Once again here is the updated .htaccess with all alterations:

RewriteEngine On

# RewriteBase /

##### Protect images from hotlinking
RewriteCond %{HTTP_REFERER} !^-?$
RewriteCond %{HTTP_REFERER} !^http://(www.)?example.com/.*$ [NC]

RewriteRule \.(gif|jpe?g|png)$ - [F]

##### Resolve index.html to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html?\ HTTP/
RewriteRule ^index\.html$ http://www.example.com/ [R=301,L]

##### Resolve canonical domains
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

##### Rewrite function 1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^test/(.*)$ test/rewrite.php?url=$1 [L]

##### Rewrite function 2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ rewrite.php?url=$1 [L]


I have split the Rewrite function into 2 separate conditions, and modified the construct as suggested for the HTTP_HOST condition. I also added L to the canonical rule.

I am aware that I can further optimise each expression, however for the sake of this thread I am more concerned about structure and flow.

Is there anything wrong with the above code snippet now?
Much appreciated.


Thread source:: http://www.webmasterworld.com/apache/4353045.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com