1

I have a PHP script located at http://sb1.dev.codeanywhere.net/~a70097sb/hc/onlinestatus/image.php that requires two GET variables: ign and style. My .htaccess file is in the same directory as image.php.

I want requests of the form http://sb1.dev.codeanywhere.net/~a70097sb/hc/onlinestatus/{style}/{ign}.png to be rewritten to http://sb1.dev.codeanywhere.net/~a70097sb/hc/onlinestatus/image.php?style={style}&ign={ign}. How do I do this, as I have no experience with mod_rewrite, and wasn't able to get it to work using any of the tutorials I found on Google.

Tried this but it didn't work, I just get a 404 page:

Options +FollowSymlinks -MultiViews
RewriteEngine on

RewriteRule ^([^.]*)/([^.]*)\.png$ image.php?style=$1&ign=$2 [L,NC]

2 Answers 2

3

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]
Sign up to request clarification or add additional context in comments.

8 Comments

Neither answer seems to be working. See my updated question, I included the actual site because I think it might have something to do with the subdomains. I added ~a70097sb/ to the beginning of each of those paths too and it still didn't work.
@DC_ see my update - sorry, I missed the part about your .htaccess being in the image.php directory.
@DC_ You need to look in your server's error log to see what the actual 500 error is.
Check it now, should be back to 404. The 500 error was from when I was messing around with it.
|
0

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.