0

I have a directory for uploaded photos, sorted with date, like this:

http://example.com/uploads/2012-12-08/abcd.png 

and I created an index.php inside my /uploads/ folder with a .htaccess

I could use the index.php to control the image width and height.

the original url looks like this: http://example.com/uploads/?url=2012-12-08/abcd.png&width=128.

Here's the .htaccess code:

<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*) /uploads/index.php?url=$1 [QSA] </IfModule> 

And if I enter the URL: http://example.com/uploads/2012-12-08/abcd.png&width=128 will appear the resized image

but the issue is the browser display the image extension as png&width=128

also the image URL cannot be shown in some forums, because the & symbol.

how can I change the .png&width=128 into .png?width=128?

I have tried many rules but none work.

0

2 Answers 2

1

You can try with:

RewriteCond %{QUERY_STRING} (.+) RewriteRule ^(.*)$ /uploads/index.php?url=$1&%1 [QSA] 
Sign up to request clarification or add additional context in comments.

6 Comments

but there're more that two query string,maximum : ?url=$&width=$&height=$&rotate=$&filter=$&
I tested it here htaccess.madewithlove.be and it works! So, if it isn't working, paste your full .htaccess file content
but I entered .jpg?width=256 the width didn't change,my htaccess file same as yours,just add rewriteengine on in the first line,my htaccess inside the uploads folder,also had one in the parent folder
[Sun Dec 09 03:48:34 2012] [warn] RewriteCond: NoCase option for non-regex pattern '-f' is not supported and will be ignored. '
yea I get the log,see the reply upside
|
0

Try with URL Friendly:

http://mysite.com/uploads/2012-12-08/abcd.png/128 

Info: http://zenverse.net/seo-friendly-urls-with-htaccess/

I hope it helps somewhat.

Regards.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.