HTACCESS 查询字符串不再工作


HTACCESS Query String doesn't work anymore

我'在HTACCESS for Custom PHP website中使用此代码块。当我在脚本上回显 p1 变量时,我得到如下值:

专辑/混音母带-38

而 p1 的值应该只是

影集

当我回显出 p2 值它的空白时,p2 值的值应该是

混音大师-38

HTACCESS

        Options +FollowSymlinks
        ## Mod_rewrite in use.
        RewriteEngine on
        ## Prevent Directory Listing
        IndexIgnore *
        # ---- Make pages render without their extension in the url
        Options +MultiViews
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*/([a-zA-Z0-9_-]+)|([a-zA-Z0-9_-]+))$ ./index.php?p1=$1&p2=$2&p3=$3&p4=$4&p5=$5 [L]
        RewriteRule ^(.*/([a-zA-Z0-9_-]+)|([a-zA-Z0-9_-]+))$ ./index.php?p1=$1&p2=$2&p3=$3&p4=$4 [L]
        RewriteRule ^(.*/([a-zA-Z0-9_-]+)|([a-zA-Z0-9_-]+))$ ./index.php?p1=$1&p2=$2&p3=$3 [L]
        RewriteRule ^(.*/([a-zA-Z0-9_-]+)|([a-zA-Z0-9_-]+))$ ./index.php?p1=$1&p2=$2 [L]
        RewriteRule ^(.*/([a-zA-Z0-9_-]+)|([a-zA-Z0-9_-]+))$ ./index.php?p1=$1 [L]

则表达式开头的.*专辑部分匹配。要单独捕获它,您可以将其放在括号中,这样您就有: ^((.*)/([a-zA-Z0-9_-]+)|([a-zA-Z0-9_-]+))$

请注意,此更改将移动偏移量,因此您可能需要更改 $1 -> $2 等,或者使外部括号不捕获。