Forum Moderators: phranque

Message Too Old, No Replies

getting a domain and stopping access to a old directory

         

mikeyr

10:43 pm on Aug 23, 2005 (gmt 0)

10+ Year Member



I have had a small website up for several years that was a sub-dir on my ISP's web space. Something like www.mydomain.com/subdir/index.html and now I have acquired a domain name for my pages. So it is now www.my_new_domain.com/index.html.

What do I need to do? I would like to delete the files on my old subdir and redirect people to the new domain, can I delete? and how do I redirect? I have read about htaccess and 301 but I think I need the files there to do that. Also, if I leave the files in my old subdir, wont that cause problems because of duplicate sites with search engines? Does a re-write doing a redirect also tell search engines that this subdir is gone and go to the new place.

Its all functional now and I have submitted the new site so I need to worry about duplicate text on the sites (I just read about that here less than 2 minutes ago, so still not sure) and of course I don't want to kill my old site, just the subdir. There was only 11 HTML files in the subdir, the new domain will have about 20 so I was thinking of just doing redirect within the 11 HTML files, would that work?

Mike

jdMorgan

1:44 am on Aug 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Mike,

Your set-up is not clear to me. Have you got a new directory or subdirectory on the same server, a new server, or is the only change that you want to make limited to changing the domain at which your files should be accessed?

Do you know if you can use mod_rewrite? Depending on your set-up, this may be critical to reaching your goal, but many low-cost/no-cost hosting services won't allow you to use it. This is because mod_rewrite is powerful and can be very complex, and it can raise their support costs dramatically. Before this thread turns techincal, it would be helpful to know what your options are.

Jim

mikeyr

1:53 am on Aug 24, 2005 (gmt 0)

10+ Year Member



same machine but different domain and different directories on the drive.

old was www.mydomain.com/subdir/ physically was /home/html/mydomain/public_html/subir

now I have a domain for that site so it is
www.my_NEW_domain.com/ physically its /home/html/my_NEW_domain/public_html/

Basically, I had a domain with these people and I built a site in a subdirectory of that domain, I decided to get a second domain from them and would like to discontinue the old subdir and read here about duplicate content problems, and as a result, just want to redirect (permanently move) the old stuff. I should have access to rewrite as I can do .htacess in both site.

Not sure I am explaining myself correctly, sorry.

jdMorgan

2:07 am on Aug 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The main confusion is that you are mixing the URL-view (domains and URLs) with the server filesystem view (directories, subdirectories, and file names). While it makes discussing these things a bit difficult, it is also what makes what you want to do possible.

mod_rewrite sits right on the border between the URL-view and the filesystem view, which makes it both powerful and sometimes a bit difficult to grasp. Suffice it to say that a URL need have absolutely nothing in common with a filepath, and that is what makes URL-rewriting possible.

Assuming that all traffic is pointed to your top-level Web directory, then something like the following is what you need. It is not my intent to provide you with a complete solution, but rather to get you started. Valuable references can be found in our forum charter and in the WebmasterWorld library, in the Apache Server section.


Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?old_domain\.com
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

This will permanently redirect all requests for resources in the old domain to the same-named resources in the new domain. If you previously "exposed" your subdirectory name -- that is, if it appeared in your URLs -- then you may need to modify the rule above to strip it out, or you may need to put this code into that subdirectory.

Jim

mikeyr

2:53 am on Aug 24, 2005 (gmt 0)

10+ Year Member



I guess that is my problem, I did expose the old directory name. I just created a subdir on my works website for my car and told people to start using that url. I did this of course with my bosses permission. Now, I only want to move the files from the subdir to the top level of the new domain, leaving the top level of the old site alone (or boss would be upset)

I will try this rewrite this evening. Thank You

mikeyr

3:23 am on Aug 24, 2005 (gmt 0)

10+ Year Member



It worked! Thank You, I put it in the subdirectory and then I forgot to restart Apache at first.

Its working fine, will this redirect robots too? I will go read some more in the suggested Apache section to see if there is anything else I should/must do.

Cool!

jdMorgan

9:32 pm on Aug 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, it will redirect any HTTP client.

Glad you got it working!

Jim