【问题标题】:htaccess mod_rewrite with 2.4 apache not working as expectedhtaccess mod_rewrite 与 2.4 apache 未按预期工作
【发布时间】:2016-05-31 02:03:45
【问题描述】:

这是我所有的 htaccess 代码

   #Options -MultiViews

   RewriteEngine on

   RewriteBase /

   RewriteCond %{REQUEST_FILENAME} !-d

   RewriteCond %{REQUEST_FILENAME} !-f

#
#  This Conditions is for admin
#

   RewriteRule   ^admin/$                     admin/index.php                   [L]
   RewriteRule   ^admin/(index|login|process|action|logout|ajax|controller).php  admin/$1.php?             [QSA,L]
   RewriteRule   ^admin/(.*).php             admin/controller.php?plugin=$1                    [QSA,L]
   RewriteRule   ^admin/(.*)                  admin/router.php?t=$1                             [QSA,L]

#
#  This Conditions is for Themes
#

   RewriteRule   ^theme/(.*)    view/themes/$1                  [QSA,L]

   RewriteRule   ^admin_theme/(.*) view/admins/$1               [QSA,L]

#
#  This Conditions is for App
#
   RewriteRule   ^(.*).(css|js|png|jpg|jpeg|gif|woff|ttf|otf|mp3|mp4|ogg)$       app/$1.$2      [QSA,L]

   RewriteRule   (post_comment|feed|login|action|reset|index).php       app/$1.php            [QSA,L]

   RewriteRule   ^$             app/index.php                   [L]

   RewriteRule   ^(.*)?         app/router.php?regex=$1              [QSA,L]

   RewriteRule   (.*)           app/$1                          [QSA,L]

一切正常,但这种情况

RewriteRule ^admin/(.*).php admin/controller.php?plugin=$1 [QSA,L]

重定向到这个链接 /app/router.php?regex=site.com/admin/users.php

但我应该是这样的

site.com/admin/controller.php?plugin=users&

我正在使用 localhost **xampp* 没有发现问题

但在上传到服务器 apache 2.4 后出现问题

我正在使用这个网站来检查我的 htaccess 代码

http://htaccess.mwl.be/

这里有什么问题以及这应该如何与 apache 2.4 一起工作

【问题讨论】:

    标签: php .htaccess mod-rewrite


    【解决方案1】:

    用反斜杠\.转义特殊字符.

    RewriteCond %{HTTP_HOST} ^alalmea.art4muslim.net
    RewriteRule ^admin/(.*)\.php  /admin/controller.php?plugin=$1     [QSA,L]
    

    对于 PCRE 和大多数其他所谓的 Perl 兼容风格,请转义这些外部字符类:

    .^$*+?()[{\|
    

    【讨论】:

    猜你喜欢
    • 2016-03-31
    • 2019-03-15
    • 1970-01-01
    • 2016-01-19
    • 1970-01-01
    • 1970-01-01
    • 2016-05-09
    • 2018-09-14
    • 2023-03-31
    相关资源
    最近更新 更多