1

我在 .htacces 文件中使用这个重写规则

RewriteRule ^(main|login|apps|user)/?$ index.php?_app_schema=system&_app_group=$1&%{QUERY_STRING} [NC,L]
RewriteRule ^(main|login|apps|user)/([A-z0-9]+)/?$ index.php?_app_schema=system&_app_group=$1&_app_option=$2&%{QUERY_STRING} [NC,L]
RewriteRule ^(main|login|apps|user)/([A-z0-9]+)/([A-z0-9]+)/?$ index.php?_app_schema=system&_app_group=$1&_app_option=$2&_app_action=$3&%{QUERY_STRING} [NC,L]

我想避免用户这样做

mysite.com//////用户/////登录

mysite.com//main////

mysite.com///apps////app001

出于某种原因,我可以放置所有我想要的斜线。

我怎样才能避免这种情况?

4

1 回答 1

2

I think your problem is that Apache is normalizing the URL before it gets to your rules. You can access the actual request using %{THE_REQUEST} but you will want to be careful since that variable will be completely un-sanitized. I'd suggest you either use RewriteCond rules to compare THE_REQUEST to what you would like to match, or you could use RewriteCond to check for instances of multiple slashes and kick those requests out.

于 2012-12-17T22:54:07.383 回答