Forum Moderators: phranque
RewriteEngine on
RedirectPermanent /~some-user/file1.html http://www.example.com/another-file/
RedirectPermanent /~some-user/file2.html http://www.example.com/another-file2/
RedirectPermanent /~some-user/file3.html http://www.example.com/another-file3/
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} old-domain\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
The redirect from the old domain to the new one works, but the specific files are redirected to http://www.example.com/~some-user/file3.html etc.
[edited by: jdMorgan at 7:46 pm (utc) on Feb. 11, 2008]
[edit reason] example.com [/edit]
If the Redirects are correct, you should be able to fix the issue with a simple change:
RedirectPermanent /~some-user/file1.html http://www.example.com/another-file/
RedirectPermanent /~some-user/file2.html http://www.example.com/another-file2/
RedirectPermanent /~some-user/file3.html http://www.example.com/another-file3/
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} old-domain\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
** The middle two lines (%{HTTP_HOST} conditions) are probably unnecessary since you are directing all requests, unless you know you need them.
(Please, note: I DO NOT USE Mod_Alias, AKA RedirectPermanent, so you could have Greek there and I would think the code was correct)
Hope this helps.
Justin
[edited by: jdMorgan at 7:48 pm (utc) on Feb. 11, 2008]
[edit reason] example.com [/edit]
old-domain.com/~folder/file.mp3
The RedirectPermanent only matches ~some-user/file1.html, so unless you have changed the extension from the posts, a .mp3 file will only 'match' the 'catch all' (.*) of the RewriteRule.
You can:
a.) change the RedirectPermanent to the correct version.
b.) use mod_rewrite to redirect all the files EG
RewriteEngine on
RewriteRule ^~some-user/file1\.mp3$ http://www.example.com/another-file/ [R=301,L]
RewriteRule ^~some-user/file2\.mp3$ http://www.example.com/another-file2/ [R=301,L]
RewriteRule ^~some-user/file3\.mp3$ http://www.example.com/another-file3/ [R=301,L]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Please, note:
The order of the rules or redirects must be: files you want to send to a specific directory, then the 'catch all'
The specific files, must match exactly the path to the file or the Redirect or RewriteRule will fail and they will be redirected by the 'catch all'
Justin
[edited by: jdMorgan at 7:50 pm (utc) on Feb. 11, 2008]
[edit reason] example.com [/edit]
Someone won't remove broken links to mp3 files from their site, so this will now redirect them to another page saying the previous page won't remove the link. :)