[SOLVED] help with rewrite

Ted.Szukalski

Joined: 2006-06-22
Posts: 10
Posted: Mon, 2012-04-23 03:28

<a href="http://www.digital-photo.com.au/">Ted Szukalski - Gallery of Digital Photography</a>

Hi,

could some one help me with .htaccess rewrite rule? I have upgraded from Gallery 2 to Gallery 3. Google has an index of thousands of my photos from Gallery 2. Most of them enter as:
http://digital-photo.com.au/v/People/Street+Photography/Lunchtime_Scene_MG_4734.jpg.html

The same image in Gallery 3 is located at:
http://digital-photo.com.au/gallery3/index.php/People/Street-Photography/Lunchtime_Scene_MG_4734

So the rule has to:
1) replace all occurances of + to - in the url
2) remove .jpg.html from the end of url
3) finally redirect anything /v/* to /gallery3/index.php/$new url, $new url represents result from rules 1 and 2 above. This should also specify 301, moved permanently.

Silly question: which htaccess should the resulting rule be places in? /, /v or /gallery3
Thanks in advance,

Ted

 
inposure
inposure's picture

Joined: 2010-04-23
Posts: 304
Posted: Mon, 2012-04-23 07:56
<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_URI} ^/v/(.*)(\.jpg|\.gif|\.png)\.html$
        RewriteRule .* /gallery3/index.php$1    
        RewriteRule ^([^\+]*)\+([^\+]*)\+([^\+]*)\+([^\+]*)\+([^\+]*)$ $1-$2-$3-$4-$5
        RewriteRule ^([^\+]*)\+([^\+]*)\+([^\+]*)\+([^\+]*)$ $1-$2-$3-$4
        RewriteRule ^([^\+]*)\+([^\+]*)\+([^\+]*)$ $1-$2-$3
        RewriteRule ^([^\+]*)\+([^\+]*)$ $1-$2
        RewriteRule (.*)(\.jpg|\.gif|\.png)\.html /$1 [L,R=301]
</IfModule>

Add additional lines in case you have file names with more than 5 + signs.

 
Ted.Szukalski

Joined: 2006-06-22
Posts: 10
Posted: Mon, 2012-04-23 09:17

Big thank you. It worked straight away.

This is my day 1 on Gallery 3 and I am really grateful this forum exists with helpful people like you.

Ted

 
andreste

Joined: 2006-06-02
Posts: 121
Posted: Thu, 2012-07-12 10:06

(can't I delete a comment??)
Instead of here, I'm continuing on the thread I started: http://gallery.menalto.com/node/106660 , if anyone can help....