别名url上的RewriteRule

时间:2012-09-27 12:28:07

标签: php apache .htaccess kohana

查询:

domain.com/page/do

我需要:

domain.com/index.php/page/do

我使用htaccess文件,我添加了别名

RewriteBase /index.php/

我如何将RewriteRule写入此网址?

3 个答案:

答案 0 :(得分:1)

试试这个,它应该做你想要的,并且不需要在你的uri中使用index.php

###
# 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>

答案 1 :(得分:0)

试试这个:

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

答案 2 :(得分:0)

将这些规则添加到文档根目录中的htaccess文件中:

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