1

I have upgraded my gallery2 to gallery3, and notice that some links no longer resolve correctly. Since the proper way is to redirect these with a 301, that is the way I'm going. The following series need redirecting:

Folders:

  • old: /v/various/Gry/
  • new: /various/Gry/

Pages:

  • old: /v/Jacob/02112008310.jpg.html
  • new: /Jacob/02112008310

(both are of course just examples. there are 100's of folders & files to redirect...)

I think there were/are also direct links to images, but those I'm not bothering with for now.

NB. these are the existing rewrite rules:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?kohana_uri=$1 [QSA,PT,L]
RewriteRule ^$ index.php?kohana_uri=$1 [QSA,PT,L]
RewriteRule ^index.php/(.*) $1 [QSA,R,L]

Where should I insert your lines?

0

try these... I've made some examples like you mention and these worked. Let me know if you got some corner cases that these rules don't cover.

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^v/(.*[^/])/(.*[^/])/ /$1/$2/ [R=301]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^v/(.*[^/])/(.*[^/.])\.(.*).html$ /$1/$2? [R=301]
|improve this answer|||||
  • Hmm, it's not working, but that's probably because of the existing rewrite-rules... I should have mentioned those, of course... – Evert Feb 23 '11 at 13:03
  • 1
    Fixed it by changing [R=301] into [R=301,L] – Evert Feb 23 '11 at 13:40
  • If you know that the original URLs do not resolve correctly and these are sufficiently unique to never exist in the new system (which appears to be the case in the question) then there is no need to waste resources doing filesystem checks (ie. checking that the request does not map to a file or directory) before issuing the redirect. (But checking that /v/various/Gry/ is a file or that /v/Jacob/02112008310.jpg.html is a directory is probably redundant under any scenario.) – MrWhite Jul 11 '18 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.