0

我需要Apache mod-rewrite在 Codeigniter中重写 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]

它不起作用。我怎样才能做到这一点?。

4

1 回答 1

0

尝试这个:

<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'] = '';
于 2014-01-15T05:54:14.997 回答