Forum Moderators: phranque

Message Too Old, No Replies

Problem with Redirecting multple parked domains to files/folders

Redirects function, but show actual path in addressbar, not parked domain

         

Wizcrafts

4:20 am on Apr 12, 2005 (gmt 0)

10+ Year Member



This is a two part question.

#1:
I have just one master Domain, hosted on a shared Linux server, running Apache Webserver. I do not have a unique IP just for my website. My website is E Pluribus Unum on that rented server, with all sites sharing the same IP. My website has been around for some time and has a PR of 3, which is down one from last year (before I added the extra names and on a different server IP address). I have had and continue to have sub-websites that I run from directories under my web-root. For example, in addition to my main Domain, let's call it www.example.net, I host www.example.net/site2/ and www.example.net/site3/.

Back in September 2004 I took advantage of my Registrar's offer of adding some free .info Domains, in addition to purchasing two more .com Domains. All of these additional Domains are parked on example.net, as setup via my CPanel Control Panel. That's the easy part.

After obtaining all of these miscellaneous Domain names I decided to try forwarding most of these various names to unique files and directories, only defaulting a few to the root index.html file. I used .htaccess to rewrite requests for each Domain to go to the desired file or sub-directory/index.html file. All of these redirects work fine, except that the addressbar/locationbar shows the actual file path on example.net, not the virtual parked Domain name. Thus, if I setup example2.info to be redirected to www.example.net/directory1/index.html, when I type in www.example2.info it goes where I want it to go, but the addressbar displays www.example.net/directory1/index.html, not www.example2.info. I want to know how to have these redirects work silently and show the URL of the parked Domain, not the actual translated path.

Here are my obfuscated codes from my .htaccess. The first group redirect to a subdirectory, and the second to a file in the web-root:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} example1.info [OR]
RewriteCond %{HTTP_HOST} example2.info [OR]
RewriteCond %{HTTP_HOST} example3.com
RewriteRule ^(.*)$ /directory1/index.html [R=301,L]

RewriteCond %{HTTP_HOST} example4.info [OR]
RewriteCond %{HTTP_HOST} example5.info [OR]
RewriteCond %{HTTP_HOST} example6.info
RewriteRule ^(.*)$ destination_file.html [R=301,L]


As I stated, these codes function, but show the redirected URL, not the aliased URL. However, for the few parked Domains where I do not specify a redirect, the addressbar does show the parked Domain, after it lands on my master index.html. ie: www.example7.com displays just like that if I do not list it in any redirects in my .htaccess.

BTW: I searched WebmasterWorld on this subject and found another option, which caused me a 500 Server Error when I applied it. Here is the condition I tried:

RewriteCond %{HTTP_HOST} example8.info
RewriteCond %{REQUEST_URI} !^file2\.html
RewriteRule ^(.*)$ /file2.html [L]


This 500's out so I can't use it as it is written.

End Part 1

#2:
How badly are these parked Domains, with or without redirection to separate files or folders likely to affect my S.E. positioning? There are about 15 Domains between the original and parked names.

Thanks in advance, Wiz

sitz

1:10 pm on Apr 12, 2005 (gmt 0)

10+ Year Member



I can answer the first one, but I'm *not* a searchengine guy, so I can't help on the second one.

You're using 'R=301' in your RewriteRule, which by definition, issues an external redirect. If you want it to be silent, remove that flag.

Regarding the '500' error, the reason for the error is generally logged to the site's error.log. Additionally, mod_rewrite's 'RewriteLog' directive is VERY helpful in these situations:


RewriteLog /path/to/rewrite.log
RewriteLogLevel 9

Note that a) this should NOT be done on a production site taking significant traffic; the load that all this logging will generate on your server will be significant, and b) you will need write access to httpd.conf to make these changes. Read the resulting log *carefully*; the reason for the error *will* be there (I've verified that here), but it is a bit subtle. If after enabling the RewriteLog you still have questions, let us know (yes, I could feed you an answer, but I'm of the opinion that it's better to show folks how to find the answers).

One final thing; since you're adding <VirtualHost> containers to support your additional domains, I'm guessing you do have write access to your httpd.conf. If you read: [httpd.apache.org ], you will note a warning regarding the use of Rewrite directives in .htaccess files; httpd.conf is the preferred place for those directives unless there's an overriding reason not to.

Wizcrafts

3:49 pm on Apr 12, 2005 (gmt 0)

10+ Year Member



Sitz;
Thanks for the recommendation about removing the R=301 flag. I just tried that and the result was the target page displayed without any images or css rules, and javascript errors. When I checked the path to a missing image it showed (obfuscated) www.example.info/images/image1.gif not present. Ditto for the CSS and JS includes. When I removed the leading forward slash from the RewriteRule, I got a 500 Server Error.

Here is what did not work:

RewriteCond %{HTTP_HOST} (www\.)?new-name.info
RewriteRule ^(.*)$ /targetpage.html [L]


Removing the forward slash before target.html causes a 500 error.
Adding a trailing slash after new-name.info allows the page to load, but with broken CSS positioning.

The following code displays the page correctly, but has the actual (wrong) URL displayed:

RewriteCond %{HTTP_HOST} (www\.)?new-name.info
RewriteRule ^(.*)$ /targetpage.html [R=301,L]


As regards the server config files and logs, I don't have any way to access theses things. I just pay monthly rent to have my website hosted on the hosting company's server. All I can control is what is inside my web-root. I looked at the error logs from my CPanel control panel, but nothing was listed pertaining to my 500 errors. The raw access log showed the error conditions, but offered no explanation. It is obviously a bad interaction between what I typed and what this flavor of Apache wanted to see.

The virtual Domains I talked about are websites I created for myself and a few friends. I obtained the .info Domains to use as pointers to the otherwise long path names (on my account). They are merely sub-directories of my own Domain, yet they are indexed by all SEs. I just want to get rid of the confusion that can arise when somebody follows a simple "www.example.info" link and ends up seeing something like - www.mydomain.net/foobar/foobar3.html

Any other ideas?

NOTE: I just read my raw access log for my last attempts and see a lot of 304 codes for the images and scripts that did not load correctly. Could this be due to the .info redirected domain components not being loaded in the browser's cache? Hmmmm.

Wiz

jdMorgan

4:17 pm on Apr 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Wiz,

You have probably used relative URLs to reference your css and images.

Since it is the browser that resolves relative filepaths, it is trying to access them relative to the non-rewritten URL.

You can either use rooted relative URLs or add rewrites to make the css and image files 'appear' where the browser expects them to be. Rooted relative paths look like this: <img src="/image.gif"> instead of <img src="image.gif"> or <img src="../image.gif">.

Take a look at the filepaths in the 404 error log to see the effect of the browser resolving these relative URLs. That will demonstrate what you need to fix.

Jim

Wizcrafts

4:21 pm on Apr 12, 2005 (gmt 0)

10+ Year Member



Jim;
I just saw evidence of incorrect paths to and partial loads of included objects, in the raw log. Strangely the result codes are either 200 or 304, for scripts and images that did not even load in the browser.

I do use relative paths, as you deduced, since that is the only way to see the results while designing a web page offline. I guess I will need to add a leading forward slash to all images and scripts, which are indeed in their own sub-directories.

Thanks for the assistance.

Wiz

Wizcrafts

4:41 pm on Apr 12, 2005 (gmt 0)

10+ Year Member



Well, that didn't work either, dad gummit. I added a leading forward slash to all paths to scripts and images, on a mirror image page of the target file, and it still displayed totally broken. When I added a trailing slash to the HOST URL, in .htaccess, the page displayed with partial CSS support, but still broken positioning. I may have to create special target pages that have no external scripts, and use ht*p paths to my own images.

Better yet, I'll just continue to use what I had, which displays the design correctly, but not the URL.

;-(

Wiz

Wizcrafts

6:43 pm on Apr 12, 2005 (gmt 0)

10+ Year Member



I am still investigating solutions. My latest attempt involves placing all of the target files in their own single directory, named "ws". The results are still a broken layout.

Here are some of the error messages I get from my Javascript Console, on Firefox:


Error: The stylesheet [example.info...] was not loaded because its MIME type, "text/html", is not "text/css".

Error: syntax error
Source File: [example.info...]
Line: 1
Source Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

Error: The stylesheet [example.info...] was not loaded because its MIME type, "text/html", is not "text/css".

Error: syntax error
Source File: [example.info...]
Line: 1
Source Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

Error: syntax error
Source File: [example.info...]
Line: 1
Source Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

(and more js errors for included files)


I should mention that this page displays perfectly if I type it's actual path into my addressbar.

My code for the Rewrite-redirect is:

RewriteCond %{HTTP_HOST} (www\.)?example.info
RewriteCond %{REQUEST_URI}!^ws/target\.html
RewriteRule ^(.*)$ ws/target.html [L]

Any other suggestions on how I can get a transparent redirect to work correctly?

Wiz

jdMorgan

7:31 pm on Apr 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can either use rooted relative URLs or add rewrites to make the css and image files 'appear' where the browser expects them to be.

Jim