2013-08-27 91 views
0

我需要Apache mod-rewrite在笨改写笨URL与htaccess的

页名称example.com/pages/page1 重写URL,我需要通过example.com/welcome.html

重新命名它,我在htaccess文件

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

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

+0

所以,如果你直接去'example.com/welcome.html'它显示了罚款? – anubhava

+0

我使用Codeigniter“路由”http://ellislab.com/codeigniter/user-guide/general/routing.html而我做了我所需要的:) –

回答

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> 

assumming是的index.php是你的索引页。

,并在config.php变化

$config['index_page'] = '';