【问题标题】:File named index.php needed in URLURL 中需要名为 index.php 的文件
【发布时间】:2016-10-01 13:39:05
【问题描述】:

虽然 Codeigniter 托管在 Godaddy 或 Speedhost 上,但 URL 的工作方式类似于 - http://www/host_name.com/admin/home,但它不适用于 Amazon 的 Linux AMI 实例或即使是 Ubuntu 实例,因为我们需要在 URL 之间引入 index.php,如图所示下面-http://www/host_name.com/index.php/admin/home

我在项目根目录(此处为 admin_portal)中包含 .htaccess 文件,但仍然不会成功。以下是我的 .htaccess 文件的内容。

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

谢谢, 拉维

【问题讨论】:

  • 尝试使用 RewriteRule ^(.*)$ index.php/$1 [L,QSA] 或 RewriteRule ^(.*)$ index.php?/$1 [L,QSA] 或 RewriteRule ^(.*)$ index.php/?$1 [L,QSA] 代替实际的最后一行。

标签: .htaccess codeigniter httpd.conf


【解决方案1】:

确保您已启用 mod_rewrite。

如果将 apache 作为您的网络服务器运行,并且您可以访问实例上的命令 shell,则可以使用...

sudo a2enmod rewrite

然后重启服务器

sudo service apache2 restart

【讨论】:

  • 嗨,感谢您的意见。实际上,它解决了我在 /etc/httpd/conf/httpd.conf 的 apache 服务器更改 All AllowOverride None 到 AllowOverride All 中的以下设置。
  • 是的,这肯定会有所帮助!
【解决方案2】:

将此添加到您的.htaccess:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{REQUEST_URI} !^/index.php [NC]
RewriteRule ^$ /index.php    [R=301,L]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-03
    • 1970-01-01
    相关资源
    最近更新 更多