View Full Version : Need help w/ .htaccess
ShadowIce
09-27-2009, 08:31 PM
Hi, I want to allow from the STRING localhost, AND 127.0.0.1, problem is my htaccess blocks ME from entering using http://localhost instead of http://127.0.0.1..
I need to allow for both, and DENY ALL OTHER ips' from accessing the directory.
here's my code:
Order deny,allow
Deny from all
Allow from localhost
Allow from 127.0.0.1
RewriteEngine On
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
RewriteRule ^.* - [F,L]
ANY help is GREATLY appreciated! :)
clunk.werclick
09-28-2009, 08:13 PM
2 things, 1st try putting them on one line:
Allow from localhost 127.0.0.1
The second is a bit of a guess, so I apologise if I steer you up the garden path. I suspect the answer to this lives with name resolution / hosts file. For this to work at all you would need to be entering http://localhost/ in a browser on the same physical machine as Apache is running. I'm sure you are, or it would not work at all, but got to mention it.
The machine concerned resolves localhost to 127.0.0.1 OK? CLI dig localhost or nslookup localhost gives you 127.0.0.1 ?
The apache logs show the connection coming from 127.0.0.1 ?
ShadowIce
09-28-2009, 11:25 PM
Nope.
Allow from 127.0.0.1 localhost OR
Allow from localhost 127.0.0.1
BOTH return this still:
127.0.0.1 - - [28/Sep/2009:16:23:12 -0500] "GET /media/images001/ HTTP/1.1" 403 1163 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; MDDC; .NET CLR 3.5.30729; .NET CLR 3.0.30618)"
Any ideas? :/
clunk.werclick
09-29-2009, 08:19 AM
Working from that log line I'm guessing you are trying to limit access to /media/images001/ directory? I'm slightly confused because the big list of user agents you are trying to restrict are unlikely to be seen from the loopback address. I guess you are testing by modifying the USER AGENT in the HTTP request?
Can I be clear on what is happening -v- what you want to happen?
You want only http://localhost and http://127.0.0.1 to access the server directory /media/images001/. You CAN access this with http://127.0.0.1 but CANNOT access it with http://localhost (suggesting that localhost is not resolving to 127.0.0.1 - weird, but I've had a box do that myself.)
Your log entry is showing client 127.0.0.1 connecting, so this is really putting us to name resolution or Apache not doing rDNS on the IP. The HostnameLookups directive (Default: HostnameLookups off) crossed my mind, but "Regardless of the setting, when mod_access is used for controlling access by hostname, a double reverse lookup will be performed." so that looks like it's out of the park.
Some general questions that may or may not be entirely relevant - but may shed some light on what is going on:
1. Is this Apache hosted on Linux or Win?
2. Which version of Apache is running and is the site configured as a Virtual Host?
3. Does it work if you remove the .htaccess rule file (http://localhost & http://127.0.0.1 bring up a page/image)
4. Is the Apache conf allowing the the use of .htaccess (the directive for the site: AllowOverride is not set to 'none')?
5. Is the .htaccess file in the required directory: /media/images001/?
6. Is the host machine able to resolve localhost to 127.0.0.1?
This can be checked from a command prompt or shell:
LINUX WITH DIG
dig +short localhost
127.0.0.1
LINUX WITH NSLOOKUP
nslookup localhost
Server: 127.0.0.1
Address: 127.0.0.1#53
Non-authoritative answer:
Name: localhost
Address: 127.0.0.1
If not - check /etc/hosts has a line like this: 127.0.0.1 localhost
WIN WITH NSLOOKUP
Results on Windows may not be accurate - but alarm bells should ring if there is no answer for 'localhost' as it is probable Apache is using the same resolver.
C:\Documents and Settings\user1>nslookup localhost
Server: dns.lb.wh-man.zen.net.uk
Address: 212.23.6.100
Name: localhost
Address: 127.0.0.1
<tangent>
NSLOOKUP on windows appears to query the default name server and not show any results in the host file - if you have Apache running on windows and have a hosts file:
C:\WINDOWS\system32\drivers\etc\hosts with an entry like: 127.0.0.1 localhost
you may need to pay attention as to just what Apache is querying to get the host name.
</tangent>
I'm sorry I can't be more helpful than this - with a little more info I'm happy to try and recreate the issue on my test Apache.
ShadowIce
09-29-2009, 03:25 PM
Right. What I'm trying to do is block EVERY SINGLE IP from accessing my directory EXCEPT for requests from "http://localhost/" AND "http://127.0.0.1/"
i want to access BOTH "http://localhost/" AND "http://127.0.0.1/" AND MY external IP, but any other requests from an ip address are forbidden.
clunk.werclick
09-29-2009, 03:41 PM
So, does this work for either http://127.0.0.1 or http://localhost at the moment?
Does it work from one or the other but not both? Or does it not work at all?
My assumption is it does not work from http://localhost (but *does* from http://127.0.0.1) - is this correct or have I lost the plot?
ShadowIce
09-29-2009, 07:28 PM
You're correct. it works ONLY for http://127.0.0.1/. NOT http://localhost/.
clunk.werclick
09-29-2009, 07:52 PM
If you remove the access restriction - can you bring up a page with http://localhost?
If this works, then simply put Apache is probably not getting 127.0.0.1 when it tries to resolve the name 'localhost'. It does not know what 'localhost' is, it has to resolve it before it compares it to see if it == the ip you are connecting from. Does that make sense?
I had a recent Linux distro that did not have a hosts entry for localhost. So queries for 'localhost' were leaked to my DNS server which refused to resolve 'localhost'. Perhaps you have some similar malarky going on?
ShadowIce
09-29-2009, 08:35 PM
Right. So how STEP-BY-STEP would i do this?
clunk.werclick
09-29-2009, 08:48 PM
Without knowing if you can or cannot access http://localhost without the restriction it's hard to move on. It's still a guess as to what OS or Apache version you have so please read post #4 and work from there. If you have any additional troubleshooting questions when you have checked and answered those points please post them.
ShadowIce
09-29-2009, 11:51 PM
No, I mean how do I remove the "access restriction" ?
clunk.werclick
09-30-2009, 06:41 AM
Delete or comment out your .htaccess file where you have put:
Order deny,allow
Deny from all
Allow from localhost
Allow from 127.0.0.1
*or* replace with
Order allow,deny
allow from all
restart Apache just to be sure.
Basically, our goal at this stage is to make sure you can reach the server via the name http://localhost before trying to control who can access.
It would help if you could let us know which version of Apache you are running and if you are running it on Linux or Windows (with the version of Linux of Windows being even more useful).
ShadowIce
09-30-2009, 02:59 PM
When I try:
Order allow,deny
allow from all
it forbids access from both. and I'm using the apache server from xampp 1.7.2.
Stats:
Apache Version Apache/2.2.12 (Win32) DAV/2 mod_ssl/2.2.12 OpenSSL/0.9.8k mod_autoindex_color PHP/5.3.0 mod_perl/2.0.4 Perl/v5.10.0
Apache API Version 20051115
Hostname:Port localhost:80
Max Requests Per Child: 0 - Keep Alive: on - Max Per Connection: 100
Timeouts Connection: 300 - Keep-Alive: 5
Virtual Server No
Loaded Modules core mod_win32 mpm_winnt http_core mod_so mod_actions mod_alias mod_asis mod_auth_basic mod_auth_digest mod_authn_default mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_cgi mod_dav mod_dav_fs mod_dav_lock mod_dir mod_env mod_headers mod_include mod_info mod_isapi mod_log_config mod_mime mod_negotiation mod_rewrite mod_setenvif mod_ssl mod_status mod_autoindex_color mod_php5 mod_perl
Is THAT enough info? :P
Thanks!
clunk.werclick
09-30-2009, 03:52 PM
That's great info buddy :-) So it's Apache 2.2.12 running on Windows. I don't have the benefit of that at the moment, but I've run it on the S23K.
I'm afraid to 'fix' this means more questions. If you can run through these and just yes/no them, it will help get to the bottom of this. If you get bored I'll fully understand :-)
1. Which version of windows is this running on? XP home/pro / Vista / Server xxxx.
2. Has this Apache *ever* server a single page in the past when you have entered http://localhost?
3. Is this the only .htaccess file you have in place?
4. Can you paste your httpd.conf file - (suitably munged if needed).
Is THAT enough questions ? :P LOL.
ShadowIce
09-30-2009, 04:46 PM
1. Which version of windows is this running on? XP home/pro / Vista / Server xxxx.
Ans: This apache is running on Windows Vista (x86) 32-bit home edition.
2. Has this Apache *ever* server a single page in the past when you have entered http://localhost?
Ans: The Apache server has served pages in the past.
3. Is this the only .htaccess file you have in place?
Ans: No, but the other htaccess files do not have the deny all line in them.
4. Can you paste your httpd.conf file - (suitably munged if needed).
Ans: Yes.
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
# consult the online docs. You have been warned.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path. If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "logs/foo.log"
# with ServerRoot set to "C:/myxampp/xampp/apache" will be interpreted by the
# server as "C:/myxampp/xampp/apache/logs/foo.log".
#
# NOTE: Where filenames are specified, you must use forward slashes
# instead of backslashes (e.g., "c:/apache" instead of "c:\apache").
# If a drive letter is omitted, the drive on which httpd.exe is located
# will be used by default. It is recommended that you always supply
# an explicit drive letter in absolute paths to avoid confusion.
#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path. If you point
# ServerRoot at a non-local disk, be sure to point the LockFile directive
# at a local disk. If you wish to share the same ServerRoot for multiple
# httpd daemons, you will need to change at least LockFile and PidFile.
#
ServerRoot "C:/myxampp/xampp/apache"
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 0.0.0.0:80
#Listen [::]:80
Listen 80
#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule authn_alias_module modules/mod_authn_alias.so
#LoadModule authn_anon_module modules/mod_authn_anon.so
#LoadModule authn_dbd_module modules/mod_authn_dbd.so
#LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authn_file_module modules/mod_authn_file.so
#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
#LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
#LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_user_module modules/mod_authz_user.so
##LoadModule autoindex_module modules/mod_autoindex.so # replaced with autoindex_color_module
#LoadModule bucketeer_module modules/mod_bucketeer.so
#LoadModule cache_module modules/mod_cache.so
#LoadModule case_filter_module modules/mod_case_filter.so
#LoadModule case_filter_in_module modules/mod_case_filter_in.so
#LoadModule cern_meta_module modules/mod_cern_meta.so
LoadModule cgi_module modules/mod_cgi.so
#LoadModule charset_lite_module modules/mod_charset_lite.so
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule dav_lock_module modules/mod_dav_lock.so
#LoadModule dbd_module modules/mod_dbd.so
#LoadModule deflate_module modules/mod_deflate.so
LoadModule dir_module modules/mod_dir.so
#LoadModule disk_cache_module modules/mod_disk_cache.so
#LoadModule dumpio_module modules/mod_dumpio.so
#LoadModule echo_module modules/mod_echo.so
LoadModule env_module modules/mod_env.so
#LoadModule example_module modules/mod_example.so
#LoadModule expires_module modules/mod_expires.so
#LoadModule ext_filter_module modules/mod_ext_filter.so
#LoadModule file_cache_module modules/mod_file_cache.so
#LoadModule filter_module modules/mod_filter.so
LoadModule headers_module modules/mod_headers.so
#LoadModule ident_module modules/mod_ident.so
#LoadModule imagemap_module modules/mod_imagemap.so
LoadModule include_module modules/mod_include.so
LoadModule info_module modules/mod_info.so
LoadModule isapi_module modules/mod_isapi.so
#LoadModule ldap_module modules/mod_ldap.so
#LoadModule logio_module modules/mod_logio.so
LoadModule log_config_module modules/mod_log_config.so
#LoadModule log_forensic_module modules/mod_log_forensic.so
#LoadModule mem_cache_module modules/mod_mem_cache.so
LoadModule mime_module modules/mod_mime.so
#LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule negotiation_module modules/mod_negotiation.so
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
#LoadModule speling_module modules/mod_speling.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule status_module modules/mod_status.so
#LoadModule substitute_module modules/mod_substitute.so
#LoadModule unique_id_module modules/mod_unique_id.so
#LoadModule userdir_module modules/mod_userdir.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule version_module modules/mod_version.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#
# 3rd party modules
#
LoadModule autoindex_color_module modules/mod_autoindex_color.so
<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User daemon
Group daemon
</IfModule>
</IfModule>
# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition. These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#
#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed. This address appears on some server-generated pages, such
# as error documents. e.g. admin@your-domain.com
#
ServerAdmin postmaster@localhost
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName localhost:80
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "C:/myxampp/xampp/htdocs"
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "C:/myxampp/xampp/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks Includes ExecCGI
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>
#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog "logs/error.log"
#ScriptLog "logs/cgi.log"
#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn
<IfModule log_config_module>
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
#
# The location and format of the access logfile (Common Logfile Format).
# If you do not define any access logfiles within a <VirtualHost>
# container, they will be logged here. Contrariwise, if you *do*
# define per-<VirtualHost> access logfiles, transactions will be
# logged therein and *not* in this file.
#
#CustomLog "logs/access.log" common
#
# If you prefer a logfile with access, agent, and referer information
# (Combined Logfile Format) you can use the following directive.
#
CustomLog "logs/access.log" combined
</IfModule>
<IfModule alias_module>
#
# Redirect: Allows you to tell clients about documents that used to
# exist in your server's namespace, but do not anymore. The client
# will make a new request for the document at its new location.
# Example:
# Redirect permanent /foo http://localhost/bar
#
# Alias: Maps web paths into filesystem paths and is used to
# access content that does not live under the DocumentRoot.
# Example:
# Alias /webpath /full/filesystem/path
#
# If you include a trailing / on /webpath then the server will
# require it to be present in the URL. You will also likely
# need to provide a <Directory> section to allow access to
# the filesystem path.
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the target directory are treated as applications and
# run by the server when requested rather than as documents sent to the
# client. The same rules about trailing "/" apply to ScriptAlias
# directives as to Alias.
#
ScriptAlias /cgi-bin/ "C:/myxampp/xampp/cgi-bin/"
</IfModule>
<IfModule cgid_module>
#
# ScriptSock: On threaded servers, designate the path to the UNIX
# socket used to communicate with the CGI daemon of mod_cgid.
#
#Scriptsock "logs/cgi.sock"
</IfModule>
#
# "C:/myxampp/xampp/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "C:/myxampp/xampp/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
#
# DefaultType: the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value. If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
DefaultType text/plain
<IfModule mime_module>
#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig "conf/mime.types"
#
# AddType allows you to add to or override the MIME configuration
# file specified in TypesConfig for specific file types.
#
#AddType application/x-gzip .tgz
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
#
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
#
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
AddHandler cgi-script .cgi .pl .asp
# For type maps (negotiated resources):
#AddHandler type-map var
#
# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>
<IfModule mime_magic_module>
#
# The mod_mime_magic module allows the server to use various hints from the
# contents of the file itself to determine its type. The MIMEMagicFile
# directive tells the module where the hint definitions are located.
#
MIMEMagicFile "conf/magic"
</IfModule>
#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://localhost/subscription_info.html
#
#
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall is used to deliver
# files. This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
#
#EnableMMAP off
#EnableSendfile off
# Supplemental configuration
#
# The configuration files in the conf/extra/ directory can be
# included to add extra features or to modify the default configuration of
# the server, or you may simply copy their contents here and change as
# necessary.
# XAMPP specific settings
Include "conf/extra/httpd-xampp.conf"
# Perl settings
Include "conf/extra/perl.conf"
# Server-pool management (MPM specific)
Include "conf/extra/httpd-mpm.conf"
# Multi-language error messages
Include "conf/extra/httpd-multilang-errordoc.conf"
# Fancy directory listings
Include "conf/extra/httpd-autoindex.conf"
# Language settings
Include "conf/extra/httpd-languages.conf"
# User home directories
Include "conf/extra/httpd-userdir.conf"
# Real-time info on requests and configuration
Include "conf/extra/httpd-info.conf"
# Virtual hosts
Include "conf/extra/httpd-vhosts.conf"
# Distributed authoring and versioning (WebDAV)
Include "conf/extra/httpd-dav.conf"
# Implements a proxy/gateway for Apache.
Include "conf/extra/httpd-proxy.conf"
# Various default settings
Include "conf/extra/httpd-default.conf"
# Secure (SSL/TLS) connections
Include "conf/extra/httpd-ssl.conf"
#
# Note: The following must must be present to support
# starting without SSL on platforms with no /dev/random equivalent
# but a statically compiled-in mod_ssl.
#
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
SSLSessionCache "shmcb:logs/ssl.scache(512000)"
SSLSessionCacheTimeout 300
</IfModule>
Is THAT enough questions ? :P LOL.
Ans: Damn straight :P (Idk, you tell me XD)
clunk.werclick
09-30-2009, 06:21 PM
Fantastic. Vista is completely alien to me, but I've set up a virtual box to take a look. This is a virgin install - so nothing done/changed. The first thing I want to do is see how it resolves the name 'localhost'.
From a Vista command prompt I notice that pinging localhost is resolving first to an IP6
Microsoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.
C:\Users\vista>ping localhost
Pinging vista-PC [::1] from ::1 with 32 bytes of data:
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Ping statistics for ::1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
I'm undecided as to if this will be what Apache see's when resolving 'localhost'. I could stop this by commenting out the line for ::1 in the hosts file found at %SystemRoot%\system32\drivers\etc\hosts:
127.0.0.1 localhost
#::1 localhost
May be worth a quick check of that yourself.
Once I did this, it resolved as I expected it to;
C:\Users\vista>ping localhost
Pinging vista-PC [127.0.0.1] with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
A quick NSLOOKUP for localhost - gives a DNS based answer of 127.0.0.1 as it should (You also????)
C:\Users\vista>nslookup localhost
Server: UnKnown
Address: 192.168.1.99:53
Non-authoritative answer:
Name: localhost
Address: 127.0.0.1
C:\Users\vista>
That's all fine and dandy, but the resolution process is to check the hosts file first before calling out to DNS, so it may well be getting an IP6 answer. Worth commenting it out in the hosts file just to check as it only takes a few seconds and you *don't* need to reboot anything.
Methinks Apache is asking 'what is localhost' and getting the answer '::1', which whilst perfectly correct !=127.0.0.1 as it knows it. I just want to prove this theory, which may be entirely wrong. However, I'm going to 'play' some more and see if I can recreate this on Vista with xampp using your bits and pieces.
If anyone else can spot the obvious - which I am somewhat famous for missing - please jump right in.
ShadowIce
09-30-2009, 07:11 PM
I got rid of ::1
it was pissing me off.. lol
So what should i change the htaccess to?
clunk.werclick
09-30-2009, 09:16 PM
OK, I've mocked that up on Vista (man, I won't say how horrible I found it) and I can see just what you mean. I've messed with the various resolver files but I can't see just why it's refusing to allow 'localhost'. The logs show it resolving the IP to the hostname, in my case vista-pc, but even adding an entry for 'allow from vista-pc' is no go.
However, another host on the network 'sqaure' is resolved and can be added/blocked to suit.
If I'm honest, I'm struggling to see where it is resolving the names from. I've toyed with lmhosts, hosts, DNS and I'll be stuffed if I can find it.
I'm going to sleep on it and see if I have a dream of what is going on. If anyone else has a better understanding of how Vista is resolving ip to hostnames for Apache, jump right in.
ShadowIce
09-30-2009, 09:54 PM
Fo sho. I agree.
That's an uncommon security risk as well if you're in my boat.
It DEFINITELY needs fixed.
clunk.werclick
10-01-2009, 10:00 AM
Yep. This is specific to Vista -v- the xampp stack. I can recreate it everytime on Vista, yet it works totally flawlessly on Linux.
Calling 'localhost' should make *no difference* at all to the .htaccess restriction, as all that does is look at where the connection has come from, not the hostname called.
I've raised this with the Apache Guru's on the mailing list (users@httpd.apache.org) as I suspect there may be some weird security setting or name resolution issue with Vista -or even- a good ole' fashioned bug.
Well done for finding this weirdness - having had a sleepless night over it, I'm hoping one of the guru's can find the reason for it.
ShadowIce
10-01-2009, 11:50 PM
Hear from gurus yet?
clunk.werclick
10-02-2009, 09:19 AM
Not a word. Perhaps you would like to post to the Apache support list:?: and see if you have any better luck:
http://httpd.apache.org/lists.html#http-users
I did also ask on the xampp support forum, but again silence so far. It *looks* like a bug. The problem is, you cannot raise a bug with Apache on an old version of their software. The current version is: 2.2.13 - the version you are running is: 2.2.12. :-/
The next step will be to download the latest version and test to see if it happens with that: http://httpd.apache.org/download.cgi
It's *not ideal* and I suspect this *feature/bug* will also exist in this version - but at least if it's the right version a bug report can be raised. If I get the chance today, I'll download and test it myself.
clunk.werclick
10-02-2009, 12:45 PM
OK, I've removed the xampp stack and replaced it with the latest 2.2.13 build for Windows (http://httpd.apache.org/download.cgi) and the problem no longer exists.
I can't say if this was a flaw in Apache 2.2.12 (there is no bug reference for it that I can find) or if it's an issue with the xampp stack/customisation, but the latest Windows Apache works as it should with both http://localhost and http://127.0.0.1 - whilst keeping others out with a 403.
Prior to doing this I had used a plain working httpd.conf file that did not call in all the stuff the xampp default uses - but it made no difference. Either that Apache is broke, or there is something wrong with the stack as a whole. The best place to take that issue up is with the xampp support forum.
I'm not going to tell you to rip out your xampp and replace it with Apache 2.2.13 and php manually - that's a choice you need to make. All I can tell you is doing just that has worked here.
ShadowIce
10-02-2009, 03:12 PM
No man, you're totally right! I want 2.2.13! :D
That's a security flaw, and to me (being a security super encrypter), I HATE security flaws. I MUST replace it! :D
I'll let u know how it goes :)
Thanks!
ShadowIce
10-02-2009, 04:36 PM
Right.. I failed..
and not only that.. it wont read php or redirect to index.php anymore :/
Can you tell me STEP-BY-STEP how to install apache 2.1.13 w/ php enabled?
or at least link me to a DETAILED tutorial w/ pictures?
That would be GREATLY appreciated! :)
clunk.werclick
10-02-2009, 09:21 PM
I just googled and found a couple :-P
Here are a couple that cover it;
http://www.simonwhatley.co.uk/installing-php-with-apache-on-windows-vista
http://senese.wordpress.com/2007/06/06/install-php-5-under-apache-22-and-windows-vista/
Look like they cover it :-)
ShadowIce
10-03-2009, 08:44 PM
Thanks alot for all ur help mate! :)
I'll install the new apache in a bit.
But for now..
While I'm at, I might as well ask u how to STEP-BY-STEP setup an email server (that is NOT mercury mail!) >< and how to configure up until it works.
I'm not gonna waste forum space by posting this in another post :)
clunk.werclick
10-03-2009, 09:23 PM
Thanks alot for all ur help mate! :)
While I'm at, I might as well ask u how to STEP-BY-STEP setup an email server (that is NOT mercury mail!) >< and how to configure up until it works.
I'm not gonna waste forum space by posting this in another post :)
You may want to fire up another thread for that. Personally I use Postfix-v-Dovecot on Linux, but that is a *steep* learning curve. If you are running Windows and don't want to go down the 'Exchange' route, take a look at Mailenable Standard - which is free. I've had clients using it on server 2003 and XP Pro and it's pretty reasonable. I've can't cite it on Vista but I'm sure that will add some ?interesting? twists to it. LOL.
http://www.mailenable.com/standard_edition.asp
ShadowIce
10-03-2009, 11:48 PM
I personally want to use Hamster email server.
But i dont know how to configure it to where it actually SENDS mail. it will just say it as "2.msg", "4.msg", etc..
Here:
http://www.elbiah.de/hamster/pg/
clunk.werclick
10-04-2009, 10:27 AM
Never seen it before myself, but this looked like a good starting point:
There is mostly no support by mail, please use the hamster.en.* newsgroups instead, e. g. hamster.en.misc. If your provider does not offer a newsserver or if it does not carry these hamster newsgroups, you should ... ask him to do so. The hamster groups are also archived at Google Groups, where you might find solutions for any problems or where you can post questions.
http://www.elbiah.de/hamster/pg/
But visiting the hamster.en.* newsgroups found nothing other than furry rodents. The on-line documentation seems together enough - I had a quick look and I'm not seeing anything awful there. The BIG 'but' for me is it's not something well known to me. I'd hate to think of it installing something similar to dark mailer on a server. For that reason alone I would always stick to something well known and well supported.
Is there some kind of feature on there you specifically want that something like MailEnable does not offer?
Good luck with it :-)
ShadowIce
10-04-2009, 03:20 PM
The fact that Hamster is a mail SERVER, and not a client?
I think..
clunk.werclick
10-04-2009, 05:01 PM
MailEnable is a full SMTP & POP server (the free version does not offer IMAP). It's really easy to set up (I can't speak for Vista) offers basic Anti-spam (custom RBL's) and is nice and stable. I used it a couple of years ago with 25 domains on a windows Virtual Server and it never missed a beat. There is good documentation and a great support forum too.
Like running any server, you'll need to get up to speed on looking after it and, most importantly making sure it is secure - but the documentation is good and I don't think it installs as insecure from the outset.
Give it a go, I think you'll like it.
ShadowIce
10-04-2009, 07:27 PM
Ok, can you either tell me a STEP-BY-STEP guide, or link me to a STEP-BY-STEP guide on how to setup the mail server to where it will send email and not just put the email in a folder and fail to send it?
I need it to be setup for xampp.
btw. i have vista x86 - 32 bit edition. not x64 - 64 bit edition. :P so it functions like windows xp. but better :P
clunk.werclick
10-04-2009, 08:05 PM
I'm not even going to attempt it with Vista. Mr ShadowIce, that is an absolutely horrible operating system that you had me get my hands dirty with :-)
Download it from their site and install it, then come back here if you get any problems. I'm pretty sure you'll find it goes just like a charm. If you find you run into trouble, you know help is out here :-)
ShadowIce
10-09-2009, 07:17 PM
Hi man. having a MAJOR problem w/ my htaccess again...
It's returning an error 500 - page has an error thing w/ this htaccess, and it wont let me use my background pic, BUT stop leechers from downloading it at the same time like it's supposed to.
I checked it in an htaccess checker online, and it appears to be valid. BUT still doesnt work.
Can u tell me whats going on here, and how to fix it?
.htaccess:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?http://localhost/detect/mydb/Login System v.2.0/bg/ [NC]
RewriteRule \.(jpg|jpeg|png|gif|tif|tiff|bmp|exe|zip)$ - [NC,F,L]
ANY help would be GREATLY appreciated! :)
Thanks!
clunk.werclick
10-09-2009, 08:07 PM
Hi Fella,
I'm just on my way out so I've not had chance to look at this, but do I see you have some spaces in the URI ?
http://localhost/detect/mydb/Login System v.2.0/bg/
ShadowIce
10-09-2009, 08:56 PM
Ok. that fixed error 500. but it still doesnt block me from accessing the link to my background externally.
clunk.werclick
10-10-2009, 01:01 PM
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?localhost [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F,L]
Will block *any* requests for image types shown where the referer is not localhost. Will allow no referer (such as calling http://localhost directly)
Caveats;
As it is, once a blocked image is found a 403 forbidden [F] is returned, so the browser renders nothing or a blank line or two instead.
If no referer is set, the image will displayed as normal. You can easily 'cheat' the referer string using something like Firefox and Live HTTP Headers: http://livehttpheaders.mozdev.org/
Rather than giving a [F] 403, you can serve a 'get stuffed' type of image (see attached) to hotlinkers like this:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?localhost [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ nhl.jpe [L]
Here the image nhl.jpe (in the root directory of the site) is sent instead of the requested image
*note the file type .jpe is used as you are already blocking .jpg*
Enjoy ;-)
ShadowIce
10-10-2009, 02:08 PM
Ok, I need it to work for my background image... It's still not working....
clunk.werclick
10-10-2009, 02:29 PM
RewriteRule .*mybackgroundimage\.jpg$ - [F,L]
Changing mybackgroundimage\.jpg to the correct path of your background image.
Assuming:
1 you have mod rewrite enabled
2 you have NOT set the directive AllowOverride to None in the main configuration for the directory concerned.
ShadowIce
10-10-2009, 03:10 PM
now it works, BUT backwards.. it doesnt display the background, but still manages to link to the picture..
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?localhost/detect/mydb/phpmd5/LoginSystem2/bg [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite.org/detect/mydb/phpmd5/LoginSystem2/bg [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ nhl.jpg [L]
RewriteRule .*../nhl\.jpg$ - [F,L]
IndexIgnore *
it wont display the stop pic either
clunk.werclick
10-10-2009, 03:37 PM
Not sure you need to go to those lengths with the referer string. It's the host you are interested in, not the full path. Also, you've stated a last rule match, then added a line after it. I don't think it will ever parse that?
Entirely untested by me - but what about:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?(localhost|mysite.org) [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*/detect/mydb/phpmd5/LoginSystem2/bg/background\.jpg$ nhl.jpe [L]
Assuming you're 'protected' image is: /detect/mydb/phpmd5/LoginSystem2/bg/background.jpg and you have a replacement image called nhl.jpe in the root.
Untested - like I say, but the example in post 38 is working as happy as a pig in poop on my test box.
ShadowIce
10-10-2009, 08:52 PM
Ok, this is starting to x me off...
Here's what i have so i can get it overwith:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?(localhost|my.website.org) [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*/bg/FF10-tidus-yuna\.jpg$ nhl.jpe [L]
WHY does it STILL let me access the background via a link?
i HAVE nhl.jpe in my htdocs folder....
clunk.werclick
10-10-2009, 08:57 PM
I'm sorry ShadowIce. I'm no longer allowed to try and help here as I'm apparantly not posting 'quality and efficient code'. Therefore I won't be coming here any more. Perhaps superman 'Fishmonger' can step in and help you out.
Sorry Dude - people here can be so petty, I just can't be arsed with it.
ShadowIce
10-10-2009, 09:00 PM
Wait, so ur gonna wimp out just because someone flamed u in a post? unbelievable...
clunk.werclick
10-10-2009, 09:02 PM
I can't be arsed with it.
ShadowIce
10-10-2009, 09:03 PM
what the hell? i WASNT making fun of u.... sheesh. i was stating a fact...
ShadowIce
10-10-2009, 09:13 PM
im NOT flaming u, but I hope u learn ur lesson. cuz when u have no friends in the real world, its because u wimp out.. so u know what? if thats what u want, im done too.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.