Forum Moderators: phranque
#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]
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]
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
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.
Here is what did not work:
RewriteCond %{HTTP_HOST} (www\.)?new-name.info
RewriteRule ^(.*)$ /targetpage.html [L]
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
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
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
Better yet, I'll just continue to use what I had, which displays the design correctly, but not the URL.
;-(
Wiz
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)
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