logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: RewriteRule modification
Author
jjree



Joined: 10 Sep 2014
Posts: 1

PostPosted: Wed 10 Sep '14 11:21    Post subject: RewriteRule modification Reply with quote

I have these two RewriteRule lines in my htaccess, what they do is rename my photo files.
What the current code shows: MyUsername-mypicture.jpg
What I need to modify it to: mypicture.jpg

Code:
   RewriteRule ^file/pic/photo/([0-9]+)/([0-9]+)/([A-Za-z0-9]{32}+)\-(.*?)_([0-9]*?)\.(.*)$ file/pic/photo/$1/$2/$3_$5.$6
   RewriteRule ^file/pic/photo/([0-9]+)/([0-9]+)/([A-Za-z0-9]{32}+)\-(.*?)\.(.*)$ file/pic/photo/$1/$2/$3.$5


I'm only learning, but I can tell that I just remove this portion:
Code:
([A-Za-z0-9]{32}+)\-

But what about the $3, $5, $6? How do they work - I can't figure out. It's a simple modification but I'm too new to get it to work.

Please help?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Sat 17 Jan '15 23:45    Post subject: Reply with quote

The $ and the numbers are just a counting for the different regexes in the rewrite rule.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Sat 17 Jan '15 23:50    Post subject: Reply with quote

See also

amde with http://www.regextester.com/ Wink
Back to top


Reply to topic   Topic: RewriteRule modification View previous topic :: View next topic
Post new topic   Forum Index -> Apache