codeIgniter不会在一个子目录中运行 [英] CodeIgniter won't run in a subdirectory

查看:215
本文介绍了codeIgniter不会在一个子目录中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个codeIgniter安装在我们的,我复制到一个名为/ dev的子目录根Web目录下运行......我编辑的配置/ config.php文件,以反映变化,它现在是这样的:

I have a CodeIgniter install running in our root web directory that I copied into a subdirectory called /dev... I edited the config/config.php file to reflect the change so it is now like this:

$config['base_url']  = 'http://mysite.com/dev';
$config['sbase_url']     = 'https://mysite.com/dev';
$config['default_email'] = 'noreply@mysite.com';
$config['site_url']  = 'http://mysite.com/dev';

这是我的.htaccess文件:

This is my .htaccess file:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

当我将鼠标悬停在上它们是正确的站点中的任何链接,例如与我们联系页面的链接阅读www.mysite.com/dev/contact但是当我点击任何链接,我得到一个404错误...

When I hover over any links on the site they are correct, for example the contact us page link reads www.mysite.com/dev/contact but when I click any of the links I get a 404 error...

有没有共同的我失踪?什么

Is there something common I am missing?

推荐答案

启用的FollowSymLinks &放大器;添加 ./ 中的index.php在你面前重写规则:

Enable FollowSymlinks & add a ./ in front of index.php in your RewriteRule:

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On

  # block hidden directories
  RewriteRule "(^|/)\." - [F]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>

另外,我会离开的空白 $配置['BASE_URL'] =''; &放大器;构建链接时,相反,这使得移动环境中使用 BASE_URL()网​​址助手更容易(如subdir'd设备&安培;根级生产的)

Also, I would leave blank $config['base_url'] = ''; & use the base_url() url helper when constructing links instead, which makes moving environments easier (e.g. subdir'd dev & root-level production).

...当然,确保ModRewrite在你的Apache配置已启用。

... and of course, insure that ModRewrite is enabled in your Apache config.

这篇关于codeIgniter不会在一个子目录中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆