我正在尝试重写我网站上的链接。重写,我想重写后看到什么前可能存在的联系:
/index.pl?mode=users&action=add
- /users/add/
/index.pl?mode=streets&action=edit&id=7
- /streets/edit/7
/index.pl?mode=users&action=info&id=7
-/users/info/7
等等
.htaccess内容:
RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(jpe?g|gif|bmp|png|tiff|css|js)$ [NC]
RewriteRule ^([A-Za-z0-9-]+)/((edit|delete|info))/([0-9]+)$ index.pl?mode=$1&action=$2&id=$3 [L]
RewriteRule ^([A-Za-z0-9-]+)/((add))/?$ index.pl?mode=$1&action=$2 [L]
RewriteRule ^([A-Za-z0-9-]+)/?$ index.pl?mode=$1 [L]
/users/add/
或/street/add/
工作正常,但是...
问题:
/users/edit/xx
-我无法在perl脚本中接受ID。为什么?
/users/info/xx
-我什至无法进入信息部分/?mode=users&action=info&id=7
页面(它必须显示具有错误ID
Btw的空白表...我的网站具有“ switch”结构。我的意思是,如果mode是users,那么它将加载“ users.pl”,如果关于第二个问题-确保我在users.pl上有信息部分,并且链接/?mode=users&action=info&id=7
正常运行。
ps:添加了php-tag,因为它不是'perl'问题,但是php等同于perl,因此php-followers也可以帮助我
pps:对不起,我的英语不好。
您有太多的括号,这会使您的反向引用一一对应:
RewriteRule ^([A-Za-z0-9-]+)/(edit|delete|info)/([0-9]+)$ index.pl?mode=$1&action=$2&id=$3 [L]
RewriteRule ^([A-Za-z0-9-]+)/(add)/?$ index.pl?mode=$1&action=$2 [L]
这两个规则在((edit|delete|info))
和周围有太多括号((add))
(尽管$ 2正确地反向引用了它,但“ add”并没有受到影响)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句