Any mod rewrite gurus here?

Charles Kozierok

Elite Member
May 14, 2012
6,762
1
0
I just redid one of my websites and need to rewrite a couple of patterns from old to new. Any gurus on rewrite patterns around? :)

One specific pattern I need to deal with is to convert this:

Code:
slides/XXX.html
To this:

Code:
index.htm#XXX.jpg

I could do it in pieces, but I can't do a plain rule to change ".html" to ".jpg" or it will mess other things up.

The rest I can handle.

Thanks.
 
Last edited:

mv2devnull

Golden Member
Apr 13, 2010
1,539
169
106
Depending on what else you do have on those lines, this might work:
Code:
sed -i "sTslides/\([^ ]*\)\.htmlTindex.html#\1.jpgTg" filename(s)
The regular expression matching XXX is a wild guess. Do not use the inplace-flag (-i) before you know that your pattern is right.
 

Aluvus

Platinum Member
Apr 27, 2006
2,913
1
0
Code:
RewriteEngine On
RewriteRule ^slides/(.*)\.html$ /index.html#$1.jpg [PT,QSA]

I have not tested this, but it should at least be in the ballpark. The options at the end may or may not be appropriate for your specific case.