2012-09-27 95 views
0

上查詢:重寫規則對別名URL

domain.com/page/do 

我需要:

domain.com/index.php/page/do 

我使用htaccess的文件,我添加別名

RewriteBase /index.php/ 

我如何寫RewriteRule到這個URL?

+0

這是一個通用的重寫規則。有關示例,請參閱[其他問題](http://stackoverflow.com/a/265934/150634)。 –

回答

0

試試這個:

RewriteRule ^(.*)/(.*)$ /$1/$2 [L] 
0

添加這些規則的htaccess文件你的文檔根:

RewriteEngine On 
RewriteBase/
RewriteCond ^/index.php 
RewriteRule ^/?(.*)$ /index.php/$1 [L] 
1

試試這個,它應該做你想要什麼,並消除需要有指標.php in your uri

### 
# Rewrite Rules 
# 

<IfModule mod_rewrite.c> 

    ### Enable mod_rewrite 

    RewriteEngine On 
    RewriteBase/

    ### Checks if the URI request path coincides with a literal path 
    ### on the filesystem relative to the webroot. If it does not exist, 
    ### then it passes the path through index.php. 

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

</IfModule>