Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
Old 09-08-2008, 02:11 AM htaccess references
Defies a Status

Posts: 2,071
Name: carl
Location: UK
Trades: 0
Hi
I have been reading through and noticed a lot of questions about www. and none www. along with questions regarding .com/ and no / so I thought I would get a thread going to act as a resource for people wanting answers (I had a look and could not see one).
Its not meant to be all encompassing as I dont know any really advanced stuff but it covers a lot of the regular questions asked about htaccess and duplicating pages due to the prefix etc.
None of these are my creation, just things I have collected and thought I would share

#stop people viewing your htaccess file
Code:
<Files .htaccess>
order allow,deny
deny from all
</Files>
# tells apache to follow simbolic links and turn on the rewrite engine to process the code (some people say you dont need the "RewriteBase /" as its usually turned on anyway but I dont think it hurts to include it)
You only need this once in the htaccess file, before any rewrite rules etc
Code:
 
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
# Redirect /index.html requests to "/" - I have found that putting this as a 301 causes a loop
Code:
 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html 
RewriteRule ^index\.html$ http://www.yoursite.com/ [R=301,L]
# tells the server if www.yoursite.co was NOT selected go to http://www.yoursite.com
Code:
RewriteCond %{HTTP_HOST} !^www\. yoursite \.com$
RewriteRule (.*) http://www. yoursite.com/$1 [R=301,L]
# None www. to www.
Code:
RewriteCond %{HTTP_HOST} ^yoursite\.co\.uk 
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=301,L]
#www. to none www.
Code:
RewriteCond %{HTTP_HOST} !^yoursite\.co.uk$
RewriteRule (.*) http://yoursite.co.uk/$1 [R=301,L]
# set index page
Code:
DirectoryIndex index.html
# Prevent hotlinking
Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yoursite\.co\.uk
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F]
# Redirects index.htm to /
Code:
 
Redirect 301 /index.htm http://yoursite.co.uk/
#create error pages
Code:
ErrorDocument 403 /error403.html
ErrorDocument 404 /error404.html
ErrorDocument 500 /error500.html
#a list to help prevent bad bots 'n' scrappers
Code:
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR] 
RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Custo [OR] 
RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR] 
RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR] 
RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR] 
RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR] 
RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR] 
RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR] 
RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR] 
RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR] 
RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR] 
RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR] 
RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR] 
RewriteCond %{HTTP_USER_AGENT} ^HMView [OR] 
RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR] 
RewriteCond %{HTTP_USER_AGENT} Indy\ Library [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR] 
RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR] 
RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR] 
RewriteCond %{HTTP_USER_AGENT} ^larbin [OR] 
RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR] 
RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR] 
RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR] 
RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR] 
RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR] 
RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR] 
RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR] 
RewriteCond %{HTTP_USER_AGENT} ^pavuk [OR] 
RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR] 
RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR] 
RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR] 
RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR] 
RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR] 
RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR] 
RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR] 
RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR] 
RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR] 
RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Wget [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Widow [OR] 
RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Zeus [OR]
RewriteCond %{HTTP_USER_AGENT} ^ZyBorg
RewriteRule ^.* - [F,L]
Just a note but when your redirecting www. and "/" etc you should start with the most specfic and end with the most generic so the "/" rewrite would come before the www. rewrite.

Hope you find them useful.
Please feel free to add more
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by bakerc; 09-08-2008 at 02:45 AM..
bakerc is offline
Reply With Quote
View Public Profile Visit bakerc's homepage!
 
 
Register now for full access!
Old 09-08-2008, 02:32 AM Re: htaccess references
kiko5k's Avatar
Skilled Talker

Posts: 82
Trades: 0
Wow. Thanks a lot. Can I copy and paste that in my site? What is hotlinking?
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

kiko5k is offline
Reply With Quote
View Public Profile Visit kiko5k's homepage!
 
Old 09-08-2008, 02:35 AM Re: htaccess references
Defies a Status

Posts: 2,071
Name: carl
Location: UK
Trades: 0
Use can use them if you want to.

They are for the .htaccess file, not web pages (I know obvious, just stating a fact )

I would suggest testing each one prior to adding the next, and they're not in the correct order

Only use the ones you need though, for instance you wouldn't use the "none .www to .www" AND the ".www to none.www"

http://simple.wikipedia.org/wiki/Hot-linking
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by bakerc; 09-08-2008 at 02:40 AM..
bakerc is offline
Reply With Quote
View Public Profile Visit bakerc's homepage!
 
Old 09-08-2008, 02:50 AM Re: htaccess references
kiko5k's Avatar
Skilled Talker

Posts: 82
Trades: 0
I got it now. But what does a hotlinking do?
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

kiko5k is offline
Reply With Quote
View Public Profile Visit kiko5k's homepage!
 
Old 09-08-2008, 04:37 AM Re: htaccess references
Defies a Status

Posts: 2,071
Name: carl
Location: UK
Trades: 0
From the link above

Quote:
Hot-linking uses the bandwidth of the person who owns the website where the picture is stored. This costs that person money.
Its essentially bandwidth theft.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
bakerc is offline
Reply With Quote
View Public Profile Visit bakerc's homepage!
 
Reply     « Reply to htaccess references
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16041 seconds with 12 queries