Forum Moderators: phranque

Message Too Old, No Replies

quick .htaccess help

.htaccess rule for ignoring portions of the url

         

devil_dog

2:53 pm on Dec 21, 2007 (gmt 0)

10+ Year Member



Hi.

i wanna place a .htaccess in the "images" directory so that it does the following...

eg. requested image http://www.example.com/somthing/images/someone_somethere-3343.jpg
should be internally served with http://www.example.com/somthing/images/3343.jpg

I have no clue abt regex or .htaccess at all... only copy paste from forums... couldnt find a solution for this...
basically i want to ignore the portion of the URL after the last "/" and before the last "-".

I would really appreciate if anyone helps me out for this...
I am having problems getting google to recognize that the image with my news story is indeed relevant to the story,... on the last video by matt cutts it seems that the filename is also important to give some discription to the image,

jdMorgan

3:16 pm on Dec 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In /somthing/images/.htaccess, the pattern would be "^([^\-]+-)+(.+)$". This would extract everything after the last hyphen. Use the $2 back-reference to access it.

Jim

devil_dog

7:11 am on Dec 22, 2007 (gmt 0)

10+ Year Member



Thanks a lot Jim

That did the trick.