Mod rewrite with the file extensions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lauthiamkok
Forum Contributor
Posts: 153
Joined: Wed Apr 01, 2009 2:23 pm
Location: Plymouth, United Kingdom

Mod rewrite with the file extensions

Post by lauthiamkok »

Hi,

I have pictures kept in the folder like this http://www.mywebsite.com/img_content/extra/

there are list of pictures like,

1_20100321104422.jpg
hp_20100321104555.jpg
ep_m_2010032113455.gif

so I want to rewrite the url from, for instance,
http://www.mywebsite.com/img_content/ex ... 104555.jpg
to
http://www.mywebsite.com/wallpapers/hp_ ... 104555.jpg

which mean you only see this on your browser url,
http://www.mywebsite.com/wallpapers/hp_ ... 104555.jpg

this is my code in .Htaccess file but it won't work,

Code: Select all

RewriteRule ^wallpapers/([a_zA_Z0_9]+)\.(jpg|gif)$  /img_content/extra/$1.$2 [L]
Many thanks if you have any ideas.

Cheers,
Lau
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Mod rewrite with the file extensions

Post by requinix »

[a_zA_Z0_9]

You're using underscores...
lauthiamkok
Forum Contributor
Posts: 153
Joined: Wed Apr 01, 2009 2:23 pm
Location: Plymouth, United Kingdom

Re: Mod rewrite with the file extensions

Post by lauthiamkok »

got it! have changed that and it is now working thanks. :D
Post Reply