Welcome to WebmasterWorld Guest from 54.226.62.251

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Cold someone check this?

     

lee_sufc

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

10+ Year Member



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

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

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



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

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

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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

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

10+ Year Member



Cheers guys!

g1smd

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

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Post your revised code.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month