【问题标题】:Remove index.php from Codeigniter URL in Wamp从 Wamp 中的 Codeigniter URL 中删除 index.php
【发布时间】:2015-10-27 20:00:18
【问题描述】:

我在尝试从 url 中删除 index.php 时遇到很大问题

我已经搜索了很多论坛(这也是),但对我的情况没有帮助。

所以我有 config.php 文件

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

我的 .htaccess 文件在 index.php 附近的 public_html 文件夹中。

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

我打开了 rewrite_module(它正在工作)并且我的 httpd.conf AllowOverride 设置为 All

所以当我要去 mydomain.com/controller/action - 我得到 404 但是当我访问 mydomain.com/index.php/controller/action 时 - 一切正常..

我已经尝试了很多 .htaccess 示例......等等......没有任何帮助......

【问题讨论】:

  • 问题已解决,因为此问题来自 python。我昨天卸载了它。现在在我的 PC 上安装 python 后它工作正常。我在 codeigniter 中的配置是正确的。感谢 4 位帮助。

标签: codeigniter


【解决方案1】:

.htaccess(这应该放在应用程序文件夹之外)

粘贴

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

注意:有时index.php 不会在 Windows 中删除。但是,如果您将其上传到服务器,它将正常工作。这也发生在XAMPP 中,但如果我将它上传到主机(Linux)它工作正常

【讨论】:

  • 这个问题是在我从我的计算机上卸载 python 之后出现的。**LoadModule wsgi_module modules/mod_wsgi.so**。我从 httpd.conf 评论了这个但仍然没有任何改变。
  • 不用担心。如果您可以将其托管到实时服务器,请尝试一次。(甚至子域)
  • 其实我用这个设置很久了,但是昨天我卸载了python。是的,这个设置在centos上工作,因为我已经从服务器备份到我的本地计算机上工作。
  • 先生:再次安装 python 解决了这个问题。我仍然不知道 python 是如何影响 wamp 服务器的工作的。
  • 先生,这个帐户的声誉不够,但还是谢谢。
【解决方案2】:

我的配置运行良好:

config.php

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

.htaccess

# index file can be index.php, home.php, default.php etc.
DirectoryIndex index.php

# Rewrite engine
RewriteEngine On

# condition with escaping special chars
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

【讨论】:

  • 不工作! 未找到您请求的页面。
  • 检查您的 .htaccess 是否正常工作,添加://Rewrite to www Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^google.com[nc] RewriteRule ^(.*)$ http://www.google.com/$1 [r=301,nc]
猜你喜欢
  • 2014-08-19
  • 2011-10-28
  • 1970-01-01
  • 2016-05-14
  • 2014-10-28
  • 2012-06-15
  • 2012-09-21
相关资源
最近更新 更多