大家好,并在此先感谢,我想添加一个URL作为参数,但我不能。 我的原则是:
RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
(。*)(。*)?|重写规则^方式/([一 - 杂 - Z0-9] +)/ / $ info.php的用户= $ 1和2文本= $&安培;网址= $ 3
在浏览器中:
的http://本地主机/例子/信息/彼得/喜家伙/ HTTP://www.example.com
返回数组 $ _ GET
PHP
[用户] =>彼得
[文] =>喜的家伙/ HTTP:
[URL] => www.example.com
什么是正确的:
[用户] =>彼得
[文] =>嗨你好
[URL] => http://www.example.com
我希望你的帮助,感谢
解决方案 RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^信息/([A-ZA-Z0-9 |] +)/([^ /] *)/ $ info.php的用户= $ 1安培(*);?文字= $ 2及URL = $ 3 [B ,QSA]
[^ /]
表示任何字符,这不是一个斜杠。当然,这意味着,文字不能包含任何斜杠,但你的URL会正确匹配。
另外还要注意的 [B]
这是许多选项,你可以添加到重写规则之一。 [B]
意味着任何&安培;
和其他一些字符转义。所以,如果你是作为一个参数的URL都有查询字符串,它可以在 $ _ GET ['URL']
,其中它的参数,否则将有兴趣的朋友$读出p $ PTED作为新的查询字符串的一部分。
Hi all and thanks in advance, I'm trying to add a url as a parameter but I can not. My rule is:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^info/([a-zA-Z0-9|]+)/(.*)/(.*)$ info.php?user=$1&text=$2&url=$3
In the browser:
http://localhost/example/info/peter/hi guy/http://www.example.com
Return array $_GET
php
[user] => peter
[text] => hi guy / http:
[url] => www.example.com
What would be correct:
[user] => peter
[text] => hi guy
[url] => http://www.example.com
I hope your help thanks
解决方案RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^info/([a-zA-Z0-9|]+)/([^/]*)/(.*)$ info.php?user=$1&text=$2&url=$3 [B,QSA]
[^/]
means "any character that's not a slash". Naturally this means that "text" cannot contain any slashes, but your URL will be matched correctly.
Also note the [B]
which is one of many options you can add to a rewrite rule. [B]
means that any &
s and some other characters will be escaped. So if the URL that you're as a parameter has a query string, it can be read out in $_GET['url']
where its parameters would otherwise be interepreted as part of the new query string.
相关推荐
最新文章