【问题标题】:My .htaccess file is not working我的 .htaccess 文件不工作
【发布时间】:2015-05-28 18:51:01
【问题描述】:

我已将我的项目添加到免费托管 000webhost 上,我的所有文件都列在 public_html/ 目录中。 项目内置在codeigniter中。 我在 public_html/.htaccess 添加了 htaccess 文件,其中包含

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

但这对我不起作用,htaccess 有什么问题吗?

【问题讨论】:

  • 喜欢这个 RewriteRule ^(.*) /index.php?req=$1 [L,PT] ?
  • 您的 .htaccess 文件没问题。你得到什么错误信息?您是否有权访问 Web 服务器的错误日志?
  • 没有我的 js,css 文件没有被加载加上链接不起作用

标签: php codeigniter web-hosting


【解决方案1】:

我使用这个(它在本地和远程都适用于我):

DirectoryIndex index.php

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|css|js|robots\.txt)

RewriteRule ^(.*)$ index.php?/$1 [L]

您需要在根目录和子文件夹中创建一个名为“public”的文件夹,用于存放 css、js 等。

【讨论】:

  • CodeIgniter 默认在每个文件夹中都有一个index.html 文件。在大多数情况下,第一个指令应该指向那个。 DirectoryIndex index.html
【解决方案2】:

抱歉,我的 htaccess 没问题,但我的基本 url 中有一个额外的字符,这导致了问题。 再次抱歉。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-02
    • 1970-01-01
    • 1970-01-01
    • 2017-07-14
    相关资源
    最近更新 更多