homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Cold someone check this?

 7:13 pm on Oct 27, 2011 (gmt 0)

I wonder if someone could check over my htaccess file and let me know if it is OK (made a few changes recently and am paranoid that it's wrong)

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
#End Gzip

#cache html and htm files for one day
<FilesMatch ".(html|htm)$">
Header set Cache-Control "max-age=43200"

#cache css, javascript and text files for one week
<FilesMatch ".(js|css|txt)$">
Header set Cache-Control "max-age=604800"

#cache flash and images for one month
<FilesMatch ".(flv|swf|ico|gif|jpg|jpeg|png)$">
Header set Cache-Control "max-age=2592000"

#disable cache for script files
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control

#Redirect old affs
RewriteEngine on
RewriteBase /
RewriteRule ^aff/(.*) /example.htm [R=301,L]

RewriteEngine on
RewriteBase /
RewriteRule ^idevaffiliate/(.*) /example.htm [R=301,L]



 7:30 pm on Oct 27, 2011 (gmt 0)

Some quickies:

You only need to say "RewriteEngine on" once, unless you've turned it off in the meantime. (I have never seen this.)

RewriteBase / is the default. Normally you don't need it.

The "<ifmodule..." condition is almost never necessary. Either you have the module or you don't; write the htaccess accordingly.


 7:48 pm on Oct 27, 2011 (gmt 0)

The very first ruleset for the non-www to www redirect should be the very last ruleset in the file. This will stop an unwanted multiple step redirection chain for your old affiliate URLs.

example.com/aff/<anything> => www.example.com/aff/<anything> => www.example.com/example.htm

 8:49 pm on Oct 27, 2011 (gmt 0)

Cheers guys!


 9:54 pm on Oct 27, 2011 (gmt 0)

Post your revised code.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved