【问题标题】:RewriteRule on alias url别名 url 上的 RewriteRule
【发布时间】:2012-09-19 05:45:53
【问题描述】:

查询:

domain.com/page/do

我需要:

domain.com/index.php/page/do

等等

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

RewriteBase /index.php/

我如何将 RewriteRule 写入此 url?

【问题讨论】:

  • 这是一个常见的重写规则。有关示例,请参阅other questions

标签: php apache .htaccess kohana


【解决方案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>

【讨论】:

    【解决方案2】:

    试试这个:

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

    【讨论】:

      【解决方案3】:

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-10-06
        • 1970-01-01
        • 2013-05-07
        • 2020-03-08
        • 1970-01-01
        • 2016-06-05
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多