Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
859 views
in Technique[技术] by (71.8m points)

apache - htaccess url as parameter

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It's called greedy matching .. the "dot-asterisk" matches as much as it can & then backtracks. Instead use [^/] which will match up to the next slash.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...