【问题标题】:CodeIgniter on subdomain (mod_rewrite issue)子域上的 CodeIgniter(mod_rewrite 问题)
【发布时间】:2011-07-21 13:20:49
【问题描述】:

谁能告诉我如何让 mod_rewrite 在子域上工作?这里的 htaccess 代码http://codeigniter.com/user_guide/general/urls.html 仅适用于普通文件夹,而不适用于子域。

为什么会这样,我怎样才能让它工作?

谢谢。

【问题讨论】:

  • 您能详细说明一下吗?发生了什么,预期什么?等等;文件夹就是文件夹,子域只是访问“文件夹”的一种方式
  • 您是否在 application/config/config.php 文件中设置了基本 URL?
  • 这听起来像是您的服务器的问题。我们为我们的一个客户在 staging.[domain].com 子域上设置了 CI,并且我们的 .htaccess mod-rewrites 运行良好。但是,如果你能解释更多关于你所经历的事情,也许可以提供更好的答案。
  • 检查子域的虚拟主机,如果您使用的是 apache,请确保设置 AllowOverride All,而不是 AllowOverride none

标签: apache codeigniter mod-rewrite apache2


【解决方案1】:

我也遇到过这个问题。在某些主机上,这有效:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

请注意,我只是删除了第 3 行 index.php 前面的斜线。

另一种解决方案是将 RewriteBase 添加到块中,如下所示:

RewriteEngine on
RewriteBase /path/to/app
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

最后,如果您从中得到 500 个错误,您可以尝试这种技术,它适用于我尝试过的大多数服务器:http://codeigniter.com/wiki/Dreamhost_.htaccess/

【讨论】:

    猜你喜欢
    • 2013-04-04
    • 2013-05-06
    • 2012-03-25
    • 2013-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-30
    • 1970-01-01
    相关资源
    最近更新 更多