【问题标题】:.htaccess redirection issue in codeignitercodeigniter 中的 .htaccess 重定向问题
【发布时间】:2016-05-21 06:01:18
【问题描述】:

我在一个用 codeigniter 开发的网站工作, 要从 url 中删除 index.php,我在 htaccess 中编写了重写规则,现在,还有一个需要出现,即我需要将 url 中的 http:// 替换为 www,为此我编写了代码

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{HTTP_HOST} ^vrinfosystem.com$
RewriteRule (.*) http://www.vrinfosystem.com/$1 [R=301,L] 
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

但我遇到了问题,找不到样式表和 js。 我也更改了基本网址,但没有帮助。 如果我在HTTP_HOST 上方写下以下行 RewriteRule ^(.*)$ index.php?/$1 [L] 它会正常工作,但 index.php 将保留在 url 中。 我能解决这个问题吗?

【问题讨论】:

  • 应该只有一个[L],下面的其他规则将被省略。

标签: php .htaccess codeigniter


【解决方案1】:

你确定你已经改变了你的配置吗?

如果你不去 application>config>config.php 比向下滚动直到你找到这个

$config[‘index_page’] = 'index.php';

也改一下

$config[‘index_page’] = '';

【讨论】:

    【解决方案2】:

    为此有一组不同的脚本。这是唯一一个在多个网站上都对我有用

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

    【讨论】:

      猜你喜欢
      • 2016-07-02
      • 2015-04-15
      • 1970-01-01
      • 1970-01-01
      • 2011-12-17
      • 2013-05-01
      • 1970-01-01
      • 2021-09-25
      相关资源
      最近更新 更多