【问题标题】:How to redirect index.php to root using .htaccess如何使用 .htaccess 将 index.php 重定向到 root
【发布时间】:2014-11-08 06:36:23
【问题描述】:

我在 windows8.1 上安装了 xampp。我在 apache conf 文件中启用了 mod_rewrite,我正在使用 .htaccess 文件。我已经重新启动了我的网络服务器,并按照分步说明启用 .htaccess 文件和 mod 重写。

一切就绪后,我的应用程序位于http://example.com/ci/

现在我遇到的问题是,当我转到 http://example.com/ci/index 时,我被重定向到 xampp 初始屏幕。当我去http://example.com/ci/ 我很好。现在我将我的配置变量设置为 $config['index_page'] = “”;我有 htaccess 文件。

我可能只是盯着这个看很久了,但我不知道发生了什么。我知道这不是 CI 问题,问题必须出在 mod_rewrite 的某个地方,但我还没有什么想法。任何帮助将不胜感激。

下面是我的 .htaccess

 <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Removes index.php from ExpressionEngine URLs
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteCond %{REQUEST_URI} !/system/.* [NC]
    RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]


    # Directs all EE web requests through the site index file

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

 </IfModule>

 <IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
 </IfModule> 

【问题讨论】:

  • 你为什么使用http://example.com/ci/index URL,这个 .htaccess 位于哪里?
  • 您有一个名为 Ci 的控制器吗?似乎它会将您发送到未找到的页面和 index.php,它是 xamp 斜线屏幕页面

标签: php apache .htaccess codeigniter mod-rewrite


【解决方案1】:

让你的 htaccess 文件简单如下 希望它会工作

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

并在配置中定义一个默认控制器

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-19
    • 2013-08-26
    • 1970-01-01
    相关资源
    最近更新 更多