Forum Moderators: phranque
I will try to be as precise as possible.
--
Some time ago I got a a domain, I will call it www.example.com.
After a while I made a subdomain called blogs.example.com and opened three blogs there,
blogs.example.com/personalblog
blogs.example.com/businessblog
blogs.example.com/funblog
those were stored on the server in the directory /blogs/(personalblog/ etc.)
now I got me some more domains (which can be pointed on any directory on the server) and I am in the process of letting example.com die (it didnt work out).
now I want to split this content from blogs.example.com to new directories/domains.
both
blogs.example.com/personalblog (/blogs/personalblog/) and
blogs.example.com/businessblog (/blogs/personalblog/)
stay in the same directory on the server, but shall move to the domain
blogs.mynewhomepage.com (/personalblog etc.)
whereas
blogs.example.com/funblog
is on a new directory on the server (moved from /blogs/funblog/ to /funnyblog/) and has its own domain called www.funnierblog.com.
Now the whole domain/directory thing works as planned, I got it all set up with blogger, if I surf to those new domains I get what I want to see, but now I would like to set up an .htaccess file which redirects all incoming requests at blogs.example.com to the new adresses.
If anyone feels up to explaining me this in detail I would be thankful, however I would also be thankful for just some correct lines of code that I copy and paste into a .htaccess file.
Also, an important questions I didn't get answered yet after some googleing : this works for all files, including images, right? because funnyblog got a majority of its hit from the google-imagesearch and I wouldn't like that to stop working.
as I said, I would appreciate any help.
Thanx in advance, Alex
[edited by: jdMorgan at 11:28 pm (utc) on Dec. 14, 2006]
[edit reason] Example.com [/edit]
It's usually easier to get a response if you show the code you're working on -- Along with the example URL-paths, that serves as a basis for discussion. We ask that you do so in our Apache forum charter [webmasterworld.com]. Also, things get a bit slow in this forum sometimes. Since it involves a specific technology, this forum does not get the traffic levels of something like our Google search forum.
Generally, you can make RewriteRules conditional by testing for the desired/required conditions using RewriteRule and/or RewriteCond patterns. So if this case, if it is desirable to redirect only the "/blogs/personalblog" and "/blogs/businessblog" subdirectories of "blogs.example.com", you could use:
RewriteCond %{HTTP_HOST} ^blogs\.example\.com
RewriteRule ^blogs/((personalblog¦businessblog)/.*)$ http://www.mynewhomepage.com/$1 [R=301,L]
Unless you have additional code that prevents it, this redirect will apply to all URLs in the given domain and URL-paths -- pages, images, scripts, everything.
Replace the broken pipe "¦" character in the code above with a solid pipe character before use; Posting on this forum modifies the pipe character.
Jim
RewriteEngine On
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://blogs.mynewhomepage.com/$1 [R=301,L]
in each of the directories (the subfolder gets added automatically because the name of the folder stays the same, except for the funblog, but I figured that out too).
I guess there is a more smart/elegant way to do this, but it seems to work.
Also I have to say that I am not a coder at all, but from my old coding days (basic, tp, asm, c) which ended about a decade ago I still know the "concept" of coding and I am capable to edit a script if I can get info on all the commands/variables/expressions used.
Alex