htaccess url as parameter

前端 未结 4 2007
小蘑菇
小蘑菇 2020-12-12 02:32

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  
Rewr         


        
4条回答
  •  温柔的废话
    2020-12-12 03:09

    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.

提交回复
热议问题