【问题标题】:Rewrite codeigniter URL with htaccess用 htaccess 重写 codeigniter URL
【发布时间】:2014-01-15 13:54:14
【问题描述】:

我需要在 Codeigniter 中用Apache mod-rewrite 重写 URL

页面名称是example.com/pages/page1 我需要将其重命名为example.com/welcome.html

我在 htaccess 文件中写了这个规则

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^pages/page1$ welcome.html [PT,L]

它不起作用。我该怎么做?

【问题讨论】:

标签: regex apache .htaccess codeigniter mod-rewrite


【解决方案1】:

试试这个:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_URI} ^sys.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^app.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

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

假设 index.php 是您的索引页。

并更改 config.php

$config['index_page'] = '';

【讨论】:

    猜你喜欢
    • 2013-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-28
    • 2013-01-24
    • 1970-01-01
    • 2017-12-04
    • 1970-01-01
    相关资源
    最近更新 更多