How to use .htaccess to rewrite requests from image to PHP script?

后端 未结 2 1767
南方客
南方客 2021-01-23 10:56

I have a PHP script located at http://sb1.dev.codeanywhere.net/~a70097sb/hc/onlinestatus/image.php that requires two GET variables: ign an

相关标签:
2条回答
  • 2021-01-23 11:00

    You're on the right track. The capture pattern ([^/]+) matches everything up to the next /, so you'll need two of those.

    RewriteEngine On
    RewriteRule ^([^/]+)/([^/]+)\.png$ image.php?style=$1&ign=$2 [L,NC]
    
    0 讨论(0)
  • 2021-01-23 11:16

    Try something like that:

    <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteCond %{HTTP_HOST} ^www\.mysite\.com [NC]
       RewriteRule ^hc\/onlinestatus\/(.*)\/(.*)\.png /hc/onlinestatus/image.php?style=$1&ign=$2 [NC,L]
    </IfModule>
    
    0 讨论(0)
提交回复
热议问题