![](/img/trans.png)
[英]Redirect from one folder to another folder on same domain using htaccess
[英].htaccess working on one domain but not another same server
我有一個htaccess文件,它將所有URL和子域重定向到index.php。
它在一個域上運行正常,但在另一個域上運行不正常。 唯一的區別是,一個域是.ca,另一個域是.com。
它們都托管在同一服務器上。 如果有人可以告訴我此文件中是否存在引起問題的文件,這是我的訪問文件,將不勝感激。
謝謝
RewriteEngine on
#this rule removes www from the URL if its used
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
#this rule handles the subdomains
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^([a-z0-9]+)\.(.*)$ [NC]
RewriteRule ^(.*)$ index.php[L]
#this rule handles redirecting all addresses to index.php
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php
它適用於
但不在
http://admin.sherwoodmarine.ca立即更新此域,因為我在CPANEL中添加了該子域
我不需要在其他站點上添加子域,盡管htaccess照顧了它
該域的虛擬主機定義可能不允許通過.htaccess覆蓋設置。 向我們展示來自Apache配置的虛擬主機設置。
在這里查看教程: https : //help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles
(這與Ubuntu無關,但特定於Apache)。
如果設置了AllowOverride指令,則將考慮htaccess文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.