开发者

Maintain HTTP Method Type while redirecting

开发者 https://www.devze.com 2023-02-27 21:16 出处:网络
I have a problem while using .htaccess redirection: .... RewriteCond %{REQUEST_METHOD} ^GET RewriteRule ^retweet/(.*)$ /test.php?method=get&path=$1

I have a problem while using .htaccess redirection:

    ....
    RewriteCond %{REQUEST_METHOD} ^GET
    RewriteRule ^retweet/(.*)$ /test.php?method=get&path=$1  
    RewriteCond %{REQUEST_开发者_StackOverflow社区METHOD} ^PUT
    RewriteRule ^retweet/(.*)$ /test.php?method=put&path=$1  
    RewriteCond %{REQUEST_METHOD} ^DELETE
    RewriteRule ^retweet/(.*)$ /test.php?method=delete&path=$1  
    RewriteCond %{REQUEST_METHOD} ^POST
    RewriteRule ^retweet/(.*)$ /test.php?method=get&path=$1  
    RewriteRule ^retweet/(.*)$ /test.php?method=null&path=$1  

In fact, in this way, I'll always obtain null as matched HTTP method catched through PHP. I've tried also to use this simpler solution:

    RewriteRule ^(.*)$ /test.php?path=$1

But, in this way, it will always return the "GET" PHP method. Is there any solution? Thanks.


Here you go:

RewriteRule ^retweet/(.*) /test.php?method=%{REQUEST_METHOD}&path=$1
0

精彩评论

暂无评论...
验证码 换一张
取 消