homepage Welcome to WebmasterWorld Guest from 54.234.147.84
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
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?
lee_sufc




msg:4380349
 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]

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

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

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

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

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

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


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

 

lucy24




msg:4380365
 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.

g1smd




msg:4380371
 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.

Currently:
example.com/aff/<anything> => www.example.com/aff/<anything> => www.example.com/example.htm
lee_sufc




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

Cheers guys!

g1smd




msg:4380426
 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