繁体   English   中英

mod_rewrite-文件夹到参数

[英]mod_rewrite - Folder to parameters

我喜欢重写URL,但是.htaccess中的规则不匹配。 .htaccess位于“ foo”文件夹中。

URL有两种:

http://www.domain.com/foo/Fgh34R #Always 6 Chars after the "/" A-Za-z0-9
#should be redirected to
http://www.domain.com/foo/index.php?s=Fgh34R

http://www.domain.com/foo/http://www.google.com
#should be redirected to
http://www.domain.com/foo/index.php?u=http://www.google.com

到目前为止,这是我的.htaccess:

RewriteEngine On
RewriteRule ^\/(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?$ index.php?u=$1
RewriteRule ^\/([A-Za-z0-9]{0,6})$ index.php?s=$1

有人可以帮我吗?

您可以尝试以下方法。

RewriteEngine On
RewriteRule ^foo/(https?://\S+)$ foo/index.php?u=$1
RewriteRule ^foo/([a-zA-Z0-9]{6})$ foo/index.php?s=$1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM