我訪問通過domain-A.com
的根目錄下,並通過domain-B.com
.htaccess文件的mod_rewrite重定向到父目錄,而不是在文件名是在兩個目錄
所有重定向爲domain-B.com
正常工作的一個子目錄相同子目錄除了那些有same names
例如,如果根目錄下包含一個名爲abc.html
文件和子目錄還包含在這種情況下訪問domain-B.com/abc.html
文件abc.html
顯示domain-A.com/abc.html
的內容,但該URL保持不變,即domain-B.com/abc.html
我想知道如何解決這個問題。 我使用Ubuntu和這些
我已經啓用使用mod_rewrite,我已經對各種文件進行的設置sudo a2enmod rewrite
的.htaccess - 路徑的/ var/www/html等
# Do not change this line.
RewriteEngine on
# Change domain.com to be your primary main domain. http://domain-b.com/
RewriteCond %{HTTP_HOST} ^(www.)?domain-b.com$
# Change 'subfolder' to be the folder you want to redirect request to.
RewriteCond %{REQUEST_URI} !^/domain-b/
# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subfolder' to be the folder you want to use for your primary domain.
RewriteRule ^(.*)$ /domain-b/$1 [L]
# Change domain.com to be your primary domain again.
# Change 'subfolder' to be the folder you will use for your primary domain
# followed by/then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?domain-b.com$
RewriteRule ^(/)?$ domain-b/index.html [L]
的httpd.conf - 路徑的/ etc/apache2的/ conf目錄可用
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
000-default.conf - 路徑的/ etc/apache2的/網站可用
<VirtualHost *:80>
ServerAdmin [email protected]
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>
000-default.conf - 路徑的/ etc/apache2的/啓用的站點 -
<VirtualHost *:80>
ServerAdmin [email protected]
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>
它的工作,但我不得不更改域名-B/index.html文件域-B/index.php的,我不明白這種行爲背後的原因因爲我們有這個RewriteRule^/?$ domain-b/index.html [L],它應該讓用戶訪問index.html文件,但它一直在尋找domain-b/index.php。 – Sandhurst