初学者 .htaccess 问题(codeigniter 相关)

发布于 2024-11-05 20:00:09 字数 545 浏览 4 评论 0原文

我第一次为我的网站桌面版本设置 CodeIgniter,在将 AllowOverride 从 None 更改为 All 以使以下 .htaccess 规则起作用后遇到了一些问题:

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|m|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

问题是,我有一个移动版本位于 m.domain.com 的网站 - 从domain.com/m 提取其内容。当AllowOverride 为“None”时,效果非常好。现在我已将其更改为“全部”并实现了上述 .htaccess 文件 - 子域不再起作用,并且显示了“Apache 服务器的测试页”html 文件。

任何人都知道可能导致问题的原因是什么?谢谢!

I've setup CodeIgniter for my desktop version of the website for the first time, and I'm having a little problems after changing AllowOverride from None to All so that the following .htaccess rules work:

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|m|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

The problem is, I have a mobile version of the website located at m.domain.com - which pulls its content from domain.com/m. When AllowOverride was 'None', this worked perfectly. Now that I've changed it to 'All' and implemented the above .htaccess file - the subdomain no longer works and I get a "Test Page for the Apache Server" html file displayed.

Anyone have any idea what could be causing the problem?! Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

素染倾城色 2024-11-12 20:00:09

当您可以将其嵌入到虚拟主机配置中并返回到“AllowOverride None”(似乎对您来说效果更好)时,为什么您只对一个 htaccess 文件进行“AllowOverride All”?

附带说明一下,AllowOverride All 是您通常不尝试做的事情。

例子 :

<VirtualHost *:80>
    ServerAlias yourdomain.com
    DocumentRoot /var/www/
        <Directory "/var/www/folder">
                RewriteEngine On
                RewriteRule XXXXXX
        </Directory>
        <Directory "/var/www/another">
                RewriteEngine On
                RewriteRule XXXXXX
        </Directory>
</VirtualHost>

Why do you AllowOverride All for just one htaccess file when you could embed it in the vhost conf and go back to AllowOverride None where things seems to work better for you ?

On a side note AllowOverride All is something you usually try no do to.

Example :

<VirtualHost *:80>
    ServerAlias yourdomain.com
    DocumentRoot /var/www/
        <Directory "/var/www/folder">
                RewriteEngine On
                RewriteRule XXXXXX
        </Directory>
        <Directory "/var/www/another">
                RewriteEngine On
                RewriteRule XXXXXX
        </Directory>
</VirtualHost>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文