2014-06-13 33 views
0

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

有两种类型的网址:

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 

任何人可以帮助我吗?

回答

0

您可以尝试以下操作。

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

谢谢,但我编辑了我的问题。我忘记了路径中的一个文件夹(“foo”)。抱歉。你能再看一次吗?谢谢。 – alexP

+0

@alexP我更新了它。 – hwnd