【问题标题】:.htaccess linking to root.htaccess 链接到根目录
【发布时间】:2015-07-09 13:05:07
【问题描述】:

我正在使用 FTP 将 codeigniter 网站上传到服务器。我将 FTP 中的文件安排如下(我没有 10 个):

index.php 查找系统和应用程序文件夹。但我不知道如何处理 .htaccess 文件。我尝试了网络上的各种示例,这里有一个示例:

RewriteEngine on  
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 
RewriteCond %{REQUEST_URI} !^/public_html/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /public_html/$1  
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 
RewriteRule ^(/)?$ public_html/index.php [L]

这是我第一次使用 codeigniter,这个问题可能很愚蠢(对不起)。我真的很感谢我能得到的所有帮助。

我现在有另一个 .htaccess 文件,它从 url 中删除了 index.php:

RewriteEngine On
RewriteBase /example.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

【问题讨论】:

  • 你在index.php中定义了正确的路径吗?
  • 是的,这不是问题 :)

标签: php .htaccess codeigniter ftp


【解决方案1】:

如果您想从 url 中删除 index.php,请在 .htaccess 中使用以下代码

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

【讨论】:

  • @user3066691 应用程序和系统文件夹应该在public_html中
  • 请将整个项目上传到 public_html 文件夹中
  • 哈桑没关系,我也试过了,结果一样
【解决方案2】:

复制自revision 3 of the question

所以问题不在于 .htaccess!我通过制作我的来修复它 控制器首字母大写。

【讨论】:

    猜你喜欢
    • 2014-04-07
    • 1970-01-01
    • 2016-12-31
    • 1970-01-01
    • 1970-01-01
    • 2019-06-30
    • 1970-01-01
    • 2012-01-26
    • 1970-01-01
    相关资源
    最近更新 更多