Forum Moderators: phranque
If
mydomain.com/nonexistantdirectory/*
Redirect to
otherdomain.com/nonexistantdirectory/*
Or I can have it redirect all directories except the ones I specify.
If
Not mydomain.com/existantdirectory OR
Not mydomain.com/anotherexistingdirectory
Redirect to
otherdomain.com/directoryrequested
I also want to redirect the root directory to a specific directory on another domain.
If
mydomain.com
Redirect to
otherdomain.com/specificdirectory
Can anyone help? I've been trying all night using mod_rewrite and I can't get it. Thanks so much.
[edited by: jdMorgan at 3:31 am (utc) on May 4, 2007]
[edit reason] De-linked. [/edit]
First:
Welcome to WebmasterWorld!
Second:
Could you please post an exemplified version of what you have been trying to use, with some more specifics? (Then we can help you solve the problem, rather than writing the code for you. :))
I'm not sure I understand what you are trying to do…
Redirect the whole domain to different sites?
Redirect only some pieces?
Are there some directories you will still need to have access to?
You might also want to have a look in the Apache Library [webmasterworld.com] for tutorials and explanations.
Justin
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule ^(.*)$ http://www.flickr.com/$1 [R=301,L]
I'm trying to redirect any files/directories not on my server to my flickr account. When I try the above it redirects everything, even if it exists on my server.
[edited by: jdMorgan at 3:32 am (utc) on May 4, 2007]
[edit reason] de-linked. [/edit]
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L]
RewriteRule ^(.*)$ http://www.flickr.com/$1 [R=301,L]
Looks like this code works! Let me know if there's anything wrong with it that I'm not aware of.
[edited by: jdMorgan at 3:31 am (utc) on May 4, 2007]
[edit reason] de-linked. [/edit]
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) http://www.flickr.com/$1 [R=301,L]
Jim
[edited by: jdMorgan at 2:37 am (utc) on May 2, 2007]
The reason I'm doing this is because I've migrated my photo gallery to flickr. I want to send users to flickr who are viewing my base directory or are following links I can now place that are parallel to flickr's directory structure.
However, I have some directories that I've used to host my own images that are embedded in websites. For those files that exist on my server, I want to still serve them as usual.
In this case, look for anything about the filenames that you can use to make the redirect more exclusive; For example, redirect only missing media \.(jpe?g¦gif¦png¦wmv¦mpe?g¦mp3)$ files, or redirect only files in certain directories -- or both.
Jim