hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : mod_rewrite not working for vhosts/subdomains
Reply

Hosting Security and Technology Configuring and optimizing web hosting servers and operating systems, developing administration scripts, building servers, protecting against hackers, and general security (SSL certificates, etc.)
Forum Jump

mod_rewrite not working for vhosts/subdomains

Reply Post New Thread In Hosting Security and Technology Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 01-28-2006, 02:12 PM
HalfBrian HalfBrian is offline
Junior Guru Wannabe
 
Join Date: Aug 2005
Posts: 44

mod_rewrite not working for vhosts/subdomains


Hello WHT,

I recently tried to get image hotlinking working (with .htaccess) and in my web root, it works (ex: /home/www/.htaccess) and blocks images. When I try the same exact things in a subdomain/virtual host, it doesn't work (ex: /home/brian/public_html/.htaccess)

Here is the .htaccess in the vhost:

Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?(brian\.)?ifobos\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(jpe?g|gif|bmp|png)$ - [F]
And the one in my web root (/home/www) (this one works):

Code:
Redirect permanent /security.png http://www.ifobos.com/gd.php
ErrorDocument 400 /errors/400.php
ErrorDocument 401 /errors/401.php
ErrorDocument 403 /errors/403.php
ErrorDocument 404 /errors/404.php
ErrorDocument 500 /errors/500.php

#RewriteEngine On
#RewriteCond %{HTTP_REFERER} !^http://(www\.)?ifobos\.com/ [NC]
#RewriteCond %{HTTP_REFERER} !^$
#RewriteRule \.(jpe?g|gif|bmp|png)$ - [F]
httpd.conf (a bit edited and with comments taken out):

Code:
ServerRoot "/usr/local/apache2"

<IfModule !mpm_winnt.c>
<IfModule !mpm_netware.c>
#LockFile logs/accept.lock
</IfModule>
</IfModule>

<IfModule !mpm_netware.c>
<IfModule !perchild.c>
#ScoreBoardFile logs/apache_runtime_status
</IfModule>
</IfModule>

<IfModule !mpm_netware.c>
PidFile logs/httpd.pid
</IfModule>

Timeout 300

KeepAlive On

MaxKeepAliveRequests 100

KeepAliveTimeout 15

<IfModule prefork.c>
StartServers         1
MinSpareServers      1
MaxSpareServers     2
ServerLimit        64
MaxClients         64
MaxRequestsPerChild  4000
</IfModule>

<IfModule worker.c>
StartServers         2
MaxClients         150
MinSpareThreads     25
MaxSpareThreads     75 
ThreadsPerChild     25
MaxRequestsPerChild  0
</IfModule>

<IfModule perchild.c>
NumServers           5
StartThreads         5
MinSpareThreads      5
MaxSpareThreads     10
MaxThreadsPerChild  20
MaxRequestsPerChild  0
</IfModule>

<IfModule mpm_winnt.c>
ThreadsPerChild 250
MaxRequestsPerChild  0
</IfModule>

<IfModule beos.c>
StartThreads               10
MaxClients                 50
MaxRequestsPerThread       10000
</IfModule>    
                        
<IfModule mpm_netware.c>
ThreadStackSize      65536
StartThreads           250
MinSpareThreads         25
MaxSpareThreads        250
MaxThreads            1000
MaxRequestsPerChild      0
MaxMemFree             100
</IfModule>

<IfModule mpmt_os2.c>
StartServers           2
MinSpareThreads        5
MaxSpareThreads       10
MaxRequestsPerChild    0
</IfModule>

Listen 80

LoadModule php5_module        modules/libphp5.so


<IfModule !mpm_winnt.c>
<IfModule !mpm_netware.c>
User nobody
Group #-1
</IfModule>
</IfModule>

ServerAdmin admin@ifobos.com

ServerName www.ifobos.com:80

UseCanonicalName Off

DocumentRoot "/home/www"

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

<Directory /home/www>
    Options FollowSymLinks -Indexes
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

UserDir public_html

<Directory /home/*/public_html>
    AllowOverride FileInfo AuthConfig Limit Indexes
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
#    <Limit GET POST OPTIONS PROPFIND>
#        Order allow,deny
#        Allow from all
#    </Limit>
#    <LimitExcept GET POST OPTIONS PROPFIND>
#        Order deny,allow
#        Deny from all
#    </LimitExcept>
</Directory>

DirectoryIndex index.html index.php index.html.var index.htm

AccessFileName .htaccess

<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>

TypesConfig conf/mime.types

DefaultType text/plain

<IfModule mod_mime_magic.c>
    MIMEMagicFile conf/magic
</IfModule>

HostnameLookups Off

ErrorLog logs/error_log

LogLevel warn

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

CustomLog logs/access_log common
CustomLog logs/access_log2 combined

ServerTokens Full

ServerSignature EMail

Alias /icons/ "/usr/local/apache2/icons/"

<Directory "/usr/local/apache2/icons">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

AliasMatch ^/manual(?:/(?:de|en|es|fr|ja|ko|ru))?(/.*)?$ "/usr/local/apache2/manual$1"

<Directory "/usr/local/apache2/manual">
    Options Indexes
    AllowOverride None
    Order allow,deny
    Allow from all

    <Files *.html>
        SetHandler type-map
    </Files>

    SetEnvIf Request_URI ^/manual/(de|en|es|fr|ja|ko|ru)/ prefer-language=$1
    RedirectMatch 301 ^/manual(?:/(de|en|es|fr|ja|ko|ru)){2,}(/.*)?$ /manual/$1$2
</Directory>

ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"

<IfModule mod_cgid.c>
#
# Additional to mod_cgid.c settings, mod_cgid has Scriptsock <path>
# for setting UNIX socket for communicating with cgid.
#
#Scriptsock            logs/cgisock
</IfModule>

<Directory "/usr/local/apache2/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

IndexOptions FancyIndexing VersionSort

AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*

AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core

AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^

DefaultIcon /icons/unknown.gif

ReadmeName README.html
HeaderName HEADER.html

IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t

<Directory "/home/www">
 Options Indexes Includes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 Allow from all
</Directory>

<Directory "/home/host">
 Options Indexes Includes MultiViews
 AllowOverride All
</Directory>

#<Directory /home/www/errors/*.php>
# Options Indexes Includes FollowSymLinks MultiViews
#  php_admin_value open_basedir none
#  php_admin_value safe_mode 0
#</Directory>

<Directory "/home/www/">
Options FollowSymLinks
#  php_admin_value open_basedir .:/home/phphosthead.php:/home/phphostfoot.php:/home/phpBB2/:/home/www/errors/:/home/phpbbfooter.php
#  php_admin_value safe_mode 1
#  AddHandler application/x-httpd-php .html
#  AddHandler application/x-httpd-php .htm
# php_value  auto_prepend_file  /home/phphosthead.php
# php_value  auto_append_file  /home/phphostfoot.php
# AllowOverride None
#
</Directory>

#<Directory /home/www/*.php>
# Options Indexes Includes FollowSymLinks MultiViews
#  php_admin_value open_basedir none
#  php_admin_value safe_mode 0
#</Directory>

Include conf/vhosts.conf
conf/vhosts.conf:

Code:
##################################################
#           The Config file used for             #
#             adding and editing                 #
#         virtual hosts/user accounts            #
##################################################
#              Made by HalfBrian                 #
##################################################

LogFormat "%B" bwonly
NameVirtualHost 69.41.165.236

<VirtualHost 69.41.165.236>
    DocumentRoot /home/www/support
    ServerName forums.ifobos.com
    ServerAlias *.forums.ifobos.com
</VirtualHost>

<VirtualHost 69.41.165.236>
    DocumentRoot /home/www/support
    ServerName forum.ifobos.com
    ServerAlias *.forum.ifobos.com
</VirtualHost>

<VirtualHost 69.41.165.236>
    DocumentRoot /home/www/support
    ServerName support.ifobos.com
    ServerAlias *.support.ifobos.com
</VirtualHost>

<VirtualHost 69.41.165.236>
   DocumentRoot /home/mail
   ServerName mail.ifobos.com
   ServerAlias *.mail.ifobos.com
</VirtualHost>

<VirtualHost 69.41.165.236>
   DocumentRoot /home/bphp
   ServerName php.ifobos.com
   ServerAlias *.php.ifobos.com
</VirtualHost>

<VirtualHost 69.41.165.236>
   DocumentRoot /home/brian/public_html
   ServerName brian.ifobos.com
   ServerAlias *.brian.ifobos.com
   LogLevel warn
   #ErrorLog "|/usr/local/apache2/logging/elog -- halfbrian"
   #CustomLog "|/usr/local/apache2/logging/log -- halfbrian" common
   CustomLog "|/usr/local/apache2/logging/bwlog -- halfbrian" bwonly
   RewriteLog "/usr/local/apache2/logging/rwlog"
   RewriteLogLevel 9
</VirtualHost>

<VirtualHost 69.41.165.236>
   DocumentRoot /home/playground/www
   ServerName sand.ifobos.com
   ServerAlias *.sand.ifobos.com
</VirtualHost>

<VirtualHost 69.41.165.236>
   DocumentRoot /home/asdf/www
   ServerName asdf.ifobos.com
   ServerAlias *.asdf.ifobos.com
</VirtualHost>

<VirtualHost 69.41.165.236>
   DocumentRoot /home/brian/public_html/hbhc
   ServerName hbhc.ifobos.com
   ServerAlias *.hbhc.ifobos.com
</VirtualHost>

<VirtualHost 69.41.165.236>
DocumentRoot /home/jared/www
ServerName effaire.ifobos.com
   ServerAlias *.effaire.ifobos.com
</VirtualHost>
I have Apache 2.0, Fedora 4, PHP 5, and MySQL 4.1

Thanks,
Brian

Reply With Quote


Sponsored Links
  #2  
Old 01-28-2006, 10:15 PM
PerfTuner PerfTuner is offline
Web Hosting Guru
 
Join Date: Jul 2005
Posts: 256
Put
<Directory /home/brian/public_html/>
AllowOverride All
</Directory>
inside your vhost settings for brian.ifobos.com in vhosts.conf, then restart Apache.

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
European Data Center Association Forms Groups to Address Power, Data Center Control Issues Web Hosting News 2013-04-10 12:15:48
The Linux Foundation, Network Vendors Launch SDN Open Source Project Web Hosting News 2013-04-08 11:23:43
Microsoft Reaches Settlement with Nitol Botnet Host 3322.org Web Hosting News 2012-10-05 13:13:16
LulzSec Hackers Retaliate After Arrests, Deface Dozens of Panda Security Subdomains Web Hosting News 2012-03-08 10:41:26
Linux Foundation Website Down After Security Breach Last Week Web Hosting News 2011-09-12 20:32:11


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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 Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?