简体   繁体   English

.htaccess在一个域上工作,但不在另一台服务器上工作

[英].htaccess working on one domain but not another same server

I have an htaccess file that redirects ALL urls and subdomains to index.php. 我有一个htaccess文件,它将所有URL和子域重定向到index.php。

It is working fine on one domain but not on another. 它在一个域上运行正常,但在另一个域上运行不正常。 The only difference is that one domain is a .ca and the other a .com. 唯一的区别是,一个域是.ca,另一个域是.com。

They are both hosted on the same server. 它们都托管在同一服务器上。 Here is my access file if anyone can tell me if there is something in this file that is causing the problem it would be greatly appreciated. 如果有人可以告诉我此文件中是否存在引起问题的文件,这是我的访问文件,将不胜感激。

Thanks 谢谢

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

It works on 它适用于

http://admin.kaalaphp.com http://admin.kaalaphp.com

http://admin.rtbstats.com http://admin.rtbstats.com

but not on 但不在

http://admin.sherwoodmarine.ca UPDATE THIS DOMAIN WORKS NOW BECAUSE I ADDED THE SUBDOMAIN IN CPANEL http://admin.sherwoodmarine.ca立即更新此域,因为我在CPANEL中添加了该子域

I did not need to add the subdomain on the other sites though the htaccess looked after it 我不需要在其他站点上添加子域,尽管htaccess照顾了它

Virtual host definition for that domain might not allow to override settings via .htaccess. 该域的虚拟主机定义可能不允许通过.htaccess覆盖设置。 Show us virtual host settings from Apache configuration. 向我们展示来自Apache配置的虚拟主机设置。

Look at the tutorial here : https://help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles 在这里查看教程: https : //help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles

(This is not Ubuntu related, but specific to Apache). (这与Ubuntu无关,但特定于Apache)。

The htaccess file is considered if the AllowOverride directive is set. 如果设置了AllowOverride指令,则将考虑htaccess文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM