Mobile app version of vmapp.org
Login or Join
Moriarity557

: Use .htaccess to rewrite requests for a PNG as a PHP GET variable I'm REALLY bad with .htaccess files, and reading through the existing questions on SO only confuse me more (mainly because

@Moriarity557

Posted in: #Htaccess #UrlRewriting

I'm REALLY bad with .htaccess files, and reading through the existing questions on SO only confuse me more (mainly because they're all situation-specific and don't exactly apply to my situation at hand). I'm making a script that generates dynamic images through PHP. The script takes 1 variable, which makes the URL look like this:
www.example.com/script/image.php?name=esqew

However, I'd like to utilize an .htaccess file to rewrite the file to something more elegant and something my users can use on forums, like so:
www.example.com/script/esqew.png

The question, in a nutshell, is how do I rewrite the first request above to something more elegant like the second example using .htaccess?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Moriarity557

1 Comments

Sorted by latest first Latest Oldest Best

 

@Si4351233

Use this code in .htaccess file:

Options +FollowSymlinks -MultiViews
RewriteEngine on

RewriteRule ^(script)/([^.]*).png$ /image.php?name= [L,NC]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme