[英]HTACCESS Query String doesn't work anymore
I' am using this code block below in HTACCESS for Custom PHP Website. 我正在HTACCESS中使用以下代码块自定义PHP网站。 When I echo the p1 variable on the script I get values like:
当我在脚本上回显p1变量时,我得到的值如下:
album/mix-master-38
相册/混合主-38
Whereas the value of p1 should have been only 而p1的值应该仅为
album
专辑
When I echo out p2 value its blank, the value of p2 value should have been 当我回显p2值的空白时,p2值的值应为
mix-master-38
混合主-38
HTACCESS .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]
The .*
at the beginning of your regex is matching the album part. 正则表达式开头的
.*
与专辑部分匹配。 To capture it separately you could put that in parenthesis, so you'd have: ^((.*)/([a-zA-Z0-9_-]+)|([a-zA-Z0-9_-]+))$
要单独捕获它,可以将其放在括号中,因此您将具有:
^((.*)/([a-zA-Z0-9_-]+)|([a-zA-Z0-9_-]+))$
Note that this change will shift the offset, so you may want to either change $1 -> $2 and so on, or make the outside parenthesis non-capturing. 请注意,此更改将偏移偏移量,因此您可能想要更改$ 1-> $ 2,依此类推,或者使外部括号不被捕获。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.