简体   繁体   English

mod_rewrite-文件夹到参数

[英]mod_rewrite - Folder to parameters

I like to rewrite a URL but the rules in my .htaccess didn't match. 我喜欢重写URL,但是.htaccess中的规则不匹配。 The .htaccess is in the "foo" folder. .htaccess位于“ foo”文件夹中。

There are two kinds of URLs: 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

This is my .htaccess so far: 到目前为止,这是我的.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

Can anybody help me with this? 有人可以帮我吗?

You can try the following. 您可以尝试以下方法。

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