我正在尝试修改以下重写条件,以便只将以数字4开头的字符串作为变量重定向到process.php页面:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ /process.php?variable=$1 [L]因此,下面是
http://www.domain.com/4shopping将映射到
http://www.domain.com/process.php?variable=4shopping但以下内容将不会
http://www.domain.com/shopping这样做的原因是/shopping只是一个普通的页面(由Wordpress提供),而/4shopping是一个应该作为变量映射到/process.php上的代码。
发布于 2009-09-25 16:03:19
这样就可以了:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(4[^/]*)$ /process.php?variable=$1 [L]正则表达式表示:
^ Start of string
( Start capturing group (for $1)
4 A literal "4"
[^/]* Any character except "/", 0 or more times
) End capturing group
$ End of stringhttps://stackoverflow.com/questions/1478185
复制相似问题