Forum Moderators: phranque
http://example.com/my-path/displayimage.php?pos=-12345 http://example.com/path/morepath/seo-friendly-real-world-thing/ RedirectMatch permanent ^/my-path/displayimage\.php?pos=-12345$ http://example.com/path/morepath/seo-friendly-real-world-thing/ RedirectMatch permanent ^/my-path/displayimage\.php\?pos=-12345$ http://example.com/path/morepath/seo-friendly-real-world-thing/ RewriteCond %{REQUEST_URI} !^/my\-path/displayimage\.php\?pos=-12345$
RewriteRule ^/my\-path/displayimage\.php\?pos=-12345$ http://example.com/path/morepath/seo-friendly-real-world-thing/$1 [R=301,L] Any patient and detailed help would be greatly appreciated.
add a single, manual 301 redirect to avoid both a duplicate content penalty and, since I can't get this to work so far, a 404 if I simply delete the old items as I go.
This server is running Wordpress too so WP's boilerplate code is in the .htaccess file along with other historical redirects, that work, for non-Coppermine (static old html) files.
there are "hyphens" or dashes in the path both on the old uri and new, and I'm not sure if I'm supposed to escape those with a \ or not
and the issue around the .php extension (see below) and the ? that follows, along with the trailing code.
RewriteCond %{QUERY_STRING} blahblah Old uri:
http://example.com/my-path/displayimage.php?pos=-12345
Desired new uri:
http://example.com/path/morepath/seo-friendly-real-world-thing/
I've tried this:
RedirectMatch permanent ^/my-path/displayimage\.php?pos=-12345$ http://example.com/path/morepath/seo-friendly-real-world-thing/
But it does nothing.
Also tried this more complicated approach (and hope I don't have to use something like it on zillions of files):
RewriteCond %{REQUEST_URI} !^/my\-path/displayimage\.php\?pos=-12345$
RewriteRule ^/my\-path/displayimage\.php\?pos=-12345$ http://example.com/path/morepath/seo-friendly-real-world-thing/$1 [R=301,L]
RewriteCond %{QUERY_STRING} pos=-12345
RewriteRule ^my-path/displayimage\.php http://example.com/path/morepath/seo-friendly-real-world-thing/? [R=301,L] RewriteCond %{QUERY_STRING} \bpos=([^&]*)
RewriteRule ^my-path/displayimage.php /fixup.php?oldpage=%1 [L] [edited by: bill at 1:49 am (utc) on Feb 10, 2015]
[edit reason] added ? [R=301,L] to RewriteRule [/edit]
RewriteCond %{QUERY_STRING} pos=-12345
RewriteRule ^my-path/displayimage\.php http://example.com/path/morepath/seo-friendly-real-world-thing/ RewriteCond %{QUERY_STRING} pos=-12345
RewriteRule ^my-path/displayimage\.php http://example.com/path/morepath/seo-friendly-real-world-thing/? [R=301,L] but... it appended the "pos=-12345" to the end of the new url.
As a result, I'm moving them item by item
RewriteCond %{QUERY_STRING} pos=-1234
RewriteCond %{QUERY_STRING} album=123
RewriteCond %{REQUEST_FILENAME} photo_name_012345.JPG
RewriteRule ^my-path/somemore-path/yetmore-path/seo-album-name-yet-more-path/ http://example.com/path/path/path/path/path/file-name-that-seems-too-long-to-even-me_012345.jpg [R=301,L]
RewriteCond %{REQUEST_FILENAME} photo_name_012345.JPG
RewriteRule ^my-path/somemore-path/yetmore-path/seo-album-name-yet-more-path http://example.com/path/path/path/path/path/file-name-that-seems-too-long-to-even-me_012345.jpg [R=301,L]
RewriteCond %{REQUEST_FILENAME} photo_name_012345.JPG
RewriteRule ^my-path/somemore-path/yetmore-path/seo-album-name-yet-more-path/ http://example.com/path/path/path/path/path/file-name-that-seems-too-long-to-even-me_012345.jpg [R=301,L]
RewriteCond %{REQUEST_FILENAME} photo_name_012345.JPG
RewriteRule ^my-path/somemore-path/yetmore-path/seo-album-name-yet-more-path http://example.com/path/path/path/path/path/file-name-that-seems-too-long-to-even-me_012345.jpg [R=301,L]
One other difference: The extension JPG is all capped as shown on the one that is working and it is all lower "jpg" on the two that are not. Coincidence?
I don't understand what the %{REQUEST_FILENAME} part is for.
Aren't these redirects supposed to grab requests before the CMS gets a chance to tamper with things?
Do you have a bunch of jpgs, all with the identical name, located in assorted sub-sub-subdirectories deeper down in the original path?
But, again, where's the filename?
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^my-path/my-path/my-path/final-path/picture_name_012345.JPG$ http://example.com/path/my-path/my-path/my-path/final-path/picture_name_012345.jpg [R=301,L]
[edited by: aeronautic at 8:16 am (utc) on Feb 9, 2015]
RewriteCond %{HTTP_HOST} ^.*$
RewriteCond %{HTTP_HOST} example\.com RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^my-path/my-path/my-path/final-path/picture_name_012345.JPG$ http://example.com/path/my-path/my-path/my-path/final-path/picture_name_012345.jpg [R=301,L]on its own without a condition above.
completely unnecessary. Is that correct?
I thought there always had to be a condition