.htaccess正在影响错误的网站

时间:2016-07-24 19:21:29

标签: .htaccess apache2

我使用虚拟域在Ubunbu / Apache2设置上托管多个域。

我的文件结构如下所示

 - var
 - - www
 - - - html(can be viewed by visiting my public ip)
 - - - - .htaccess
 - - - domain1.com
 - - - - html(can be viewed by visiting domain1.com)
 - - - - - .htaccess
 - - - domain2.com
 - - - - html(can be viewed by visiting domain2.com)
 - - - - - .htaccess
 - - - domain3.us
 - - - - html(can be viewed by visiting domain3.com)
 - - - - - .htaccess
 - - - domain4.com
 - - - - .htaccess
 - - - - html(can be viewed by visiting domain4.us)

出于某种原因,domain4.com的.htaccess文件只会直接影响www中的html文件夹,而不是像应该的那样影响domain4.com的html文件夹。没有其他.htaccess文件正常工作。

/ var / www / html' s .htaccess文件

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule wp-login.php http://domain3.com/404e.php [R=301]
RewriteRule xmlrpc.php http://domain3.com/404e.php [R=301]

domain1.com' .htaccess文件

RewriteEngine On
RewriteRule wp-login.php http://domain1.com/404e.php [R=301]
RewriteRule xmlrpc.php http://domain1.com/404e.php [R=301]

domain2.com的.htaccess文件

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule wp-login.php http://domain2.com/404e.php [R=301]
RewriteRule xmlrpc.php http://domain2.com/404e.php [R=301]

domain3.us没有.htaccess文件。

domain4.com的.htaccess文件

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]



RewriteRule wp-login.php http://domain4.com/404e.php [R=301]
RewriteRule xmlrpc.php http://domain4.com/404e.php [R=301]
RewriteRule index.html http://domain4.com/index.php [R=301]

000-default.conf

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory /var/www/html>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>
</VirtualHost>

domain1.com.conf

<VirtualHost *:80>
    ServerName domain1.com
    ServerAlias www.domain1.com
    ServerAdmin an_email_addy@yahoo.com
    DocumentRoot /var/www/domain1.com/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined       
    <Directory /var/www/domain1.com/html>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>
</VirtualHost>

domain2.com.conf

    ServerName domain2.com
    ServerAlias www.domain2.com
    ServerAdmin anemail@gmail.com
    DocumentRoot /var/www/domain2.com/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
            <Directory /var/www/domain2.com/html>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>
</VirtualHost>

domain3.us.conf

<VirtualHost *:80>      

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/domain3.us/html
    ServerName www.domain3.us
    ServerAlias domain3.us        
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory /var/www/domain3.us/html/ >
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

</VirtualHost>

domain4.com.conf

<VirtualHost *:80>
    ServerName domain4.com
    ServerAlias www.domain4.com
    ServerAdmin anemail@gmail.com
    DocumentRoot /var/www/domain4.com/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /var/www/domain4.com/html>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

</VirtualHost>

我一直试图利用我最强大的google-fu来解决这个问题几天,并且无法弄清楚为什么domain4.com的.ht正在影响/ var / www / html /当它有自己的....或者为什么它会影响树上的任何文件夹。 如果您需要我显示任何其他信息,我会问。

我尝试做的就是让它删除页面上的扩展名。

这个404e页面是因为我注意到很多随机的ip试图专门找到这两个文件,看看我是否正在运行wordpress,我知道很可能没人会曾经看过它,但它对我来说是一个有趣的小项目,它的页面每秒刷新5次,每次刷新背景颜色和字体大小变化,字体颜色根据背景颜色的对比度而变化,所以它几乎总是可见的。但无论如何我提到404e是因为每个网站的每一个都有效。它只是我试图添加到.htaccess文件的任何其他命令什么也不做。

0 个答案:

没有答案