斜杠之后将文字与.htaccess的变量
我需要通过3个变量的URL,但使用斜线。例如,我会用这个网址:
I need to pass 3 variables with a URL but using slashes. So for example I would use this URL:
http://www.example.com/variable1/variable2/variable3
我有这个在我的.htaccess允许文本传递后的第一个变量,但我不能让其他两个才能通过,即使我补充和放大器; $ 2
I have this in my HTACCESS which allows the text after the first variable to be passed but I can't get the other two to come through, even if I add &$2
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /?([A-Za-z0-9_-]+)/?$ process.php?width=$1&height=$2 [QSA,L]
任何链接或帮助将是巨大的。
Any links or help would be great
您只在您的重写规则获取一个变量。
You are only capturing one variable in your rewrite rule.
您需要的是这样的:
RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/?$ process.php?width=$1&height=$2&third=$3 [QSA,L]
或者短了一点:
or, a bit shorter:
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/?$ process.php?width=$1&height=$2&third=$3 [QSA,L]
(即 \ W
单词字符包括字母,数字和下划线)
(the \w
word character includes letters, digits and underscores)
我仅取得了结束斜线可选的,所以这种重写规则只会做一些事情,如果恰好有3个变量。
I have made only the ending slash optional so this rewrite rule would only do something if there are exactly 3 variables.