« Mixed SSL Content Warning Secure FixedManipulating HTTP Headers with htaccess »
htaccess Tricks for Webmasters
Apache For Webmasters is some of my favorite htaccess examples from some of my favorite .htaccess tutorials. These cut-and-paste ready htaccess code snippets are very useful for website and server administrators.
.htaccess Tutorial Index | » Custom HTTP Headers
This lets google crawl, lets me access (1.1.1.1) without a password, and lets access from anyone WITH a password. It also allows for XHTML and CSS validation through w3.org
update combined allow code credit: megaspaz
AuthName "Under Development" AuthUserFile /home/askapache.com/.htpasswd AuthType basic Require valid-user Order Deny,Allow Deny from all Allow from 1.1.1.1 w3.org googlebot.com google.com google-analytics.com Satisfy Any
ErrorDocument 403 http://www.htaccesselite.com Order deny,allow Deny from all Allow from 1.1.1.1
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^1\.1\.1\.1
RewriteRule .* http://www.htaccesselite.com [R=302,L]
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^1\.1\.1\.1
RewriteCond %{REQUEST_URI} !/temporary-offline\.html$
RewriteRule .* /temporary-offline.html [R=302,L]
SetEnv TZ America/Indianapolis
Include a link to your email address in Apache-Generated Error Documents. Shows up on default Apache error pages
ServerSignature EMail SetEnv SERVER_ADMIN spamkill@spamkill.com
Turns off the address part of your Server Signature in Apache generated Error Documents.
ServerSignature Off
In your HTML directly link to the file.. Download Movie1. Now you will get a pop-up box asking whether you want to save the file or open it.
AddType application/octet-stream .avi AddType application/octet-stream .mpg AddType application/octet-stream .mov AddType application/octet-stream .pdf
When a user requests a .gif file (image/gif) the server instead of serving that .gif file it serves the results of /cgi-bin/filter.cgi
Action image/gif /cgi-bin/filter.cgi
Article: Request Methods
Script PUT /cgi-bin/upload.cgi Script HEAD /cgi-bin/head-robot.cgi
Makes image.gif, blah.html, index.cgi all act as php
ForceType application/x-httpd-php
Basically if the module is found it will perform the code inside the tag.
# any mod_rewrite directives here # any Expires Directives go here # any Header directives go here
.htaccess Tutorial Index | » Custom HTTP Headers
« Mixed SSL Content Warning Secure Fixed
Manipulating HTTP Headers with htaccess »
Tags: htaccess, htaccess tricks
The love of liberty is the love of others; the love of power is the love of ourselves.
-- William Hazlitt
Please consider donating to support active development of the free software and articles here.![]()
The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect. Tim Berners-Lee
very nice code i also done these type of code but you did very well
good keep it up:)
So, when are you going to publish this great info in a book for all us old school learners who can’t seem to absorb information without a highlighter? ,
[...] htaccess tricks for Webmasters [...]
Really one stop article for learning about .htacess.
You should put complete .htaccess file content as you explain rather than part of it. This will help immensely to users like us.
Thanks again.
Is there some htaccess rule to auto create symlinks from dir to another dir?
Hello All,
Appologies but I am having a slight problem, I am hosting mirrors for some open sourge mirrors and I am about to start for the Apache project but there is some requirements that apache has that I have never done before and I really would like some input, I have put my .htaccess file on the document root outside the apache directory and the other mirror directories, apache wants to have the following in
IndexOptions FancyIndexing NameWidth=* FoldersFirst ScanHTMLTitles DescriptionWidth=* HeaderName HEADER.html ReadmeName README.html AllowOverride FileInfo Indexes Options Indexes SymLinksIfOwnerMatch
but if i put this in and edit the path I get a 500 error, could you please tell me where I am going wrong?
Regards
Per Qvindesland
Script HEAD directive doesn’t seem to work in apache 2.2 :( any ideas?
It's very simple - you read the protocol and write the code. -Bill Joy
HTML | DCMI | GRDDL | XOXO | XDMP | XFN | DOM | XML | XHTML 1.1 Strict | CSS 2.1 | W3C | TLDP | WAI | DISA | ICSI | GIAC | SANS RR | GHOST | DEFCON | NIST | DHS CYBER | NIST | Phrack
↑ TOPExcept where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 License, just credit with a link.
This site is not supported or endorsed by The Apache Software Foundation (ASF). All software and documentation produced by The ASF is licensed. "Apache" is a trademark of The ASF. HTTPD based on NCSA HTTPd
Thanks for providing these! Some of the most powerful commands for webmasters ever. Great work.