PDA

View Full Version : Pointing second domain


progravix
2-2-04, 11:51 PM
My htaccess file includes the following code:

RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} playrewindremember.com
RewriteCond %{REQUEST_URI} !video/
RewriteRule ^(.*)$ video/$1 [L]

Now, if I try to access http://www.playrewindremember.com it shows broken images and none of the links work. The page should look like this: http://www.progravix.com/video/

I have already setup the second domain through ops a long time ago, and it has been pointing to http://www.progravix.com/ this whole time. I want it to point to the /video directory.

B&T
2-2-04, 11:55 PM
looks to me like you do not have an images directory under video, so your images cannot be found. you have one under htdocs.

progravix
2-3-04, 12:04 AM
Correct. All the images for my site reside at /images (http://www.progravix.com/images/).

The /video directory, which works under progravix.com, pulls the images from this /images directory.

Is the only way to make it work have my images in both places; every next directory level down I need to provide an images directory with all the same files?

What about the URLs that do not work. That has nothing to do with the images, right?

B&T
2-3-04, 12:09 AM
I did not try and debug your whole site. But you are referencing things with a relative address. You either need to change that, or make a copy of the lower level directories so the relative addresses still work.

In other words, if you are in htdocs and refer to an image as images/pic.jpg but then move your site to htdocs/video you are now looking in htdocs/video/images. You either need to change the code or move the images.

Same goes for links.

progravix
2-3-04, 12:15 AM
I guess this is why Powweb does not officially support this. It seems as though pointing to a subdirectory with a second domain only works if your subdomain does not reference to any other part of your site and has nothing to do with your main site/domain.

It might be a little easier to just transfer to $15 domains and pay the $5 a year for URL forwarding.

B&T
2-3-04, 12:20 AM
No, this has nothing to do with Powweb support. It has to do with how any set of directories and coding works. If you have coded a page to look in a certain place . . . that is where it is going to look.

Your code says look in images one level down from the root. So if you change the root . . .

If you want your page to always look in a certain place regardless of where you put it, and plan on moving it around, then you should not use relative addressing, but instead use the full url.

progravix
2-3-04, 12:50 AM
I only mentioned the Powweb support issue because it was mentioned in the Powweb User Help (http://help.powweb.com/tutorials/htaccess/subdomain.php).

I don't move my directories around, but I like to know before I upload a site if all the links are all properly working. GoLive notes bugs before I upload... really helpful. GoLive can't check full/absolute URLs.

I fixed the problem temporarily by creating a new directory at root which contains an html file with frames. The top frame is only 1 pixel high, and the bottom frame displays the /video code perfectly because I am referencing directly to http://www.progravix.com/video/

I don't see any other way to make this effectively work. I can recode everything and move images all over the place, but the neat freak inside of me just can't do that. I like having everything in one place. If that means I can't have a second domain point to a subdirectory with a simple htaccess trick, then that's cool. When my domain is up for renewal I will just switch to $15 domains. Much easier.

NMS
2-3-04, 03:55 AM
Your problem seemt o be solved, however this part of the tutorial might help you.

Sharing Files with Sub Domains

Please note that:

1) http://www.yoursite.com/subfolder/

is different from

2) http://subfolder.yoursite.com/

In fact if you have a link to an image (which calls /htdocs/images/) it will only show in link 1 but NOT in link 2. If you would like to share your files (such as the images) in your sub domains then the following procedure must be made:

i. Create a directory /subfolder/images

ii. In the .htaccess file (which is in the /htdocs) insert the following line:

Redirect /subfolder/images http://www.yoursite.com/images

This should be repeated for every directory above the /htdocs. If you need further help on Redirect click here.



Support does not support the help site .. it is maintained by users of this forum.

robfleming
2-3-04, 12:24 PM
Can the modified .htaccess file in the htdocs directory be safely modified to allow subdomain pointing when the website is done with Front Page 2003?

The PowWeb help page on the subject tends to discourage this by noting it does not support it and that it may damage the FP extensions.

tbonekkt
2-3-04, 12:30 PM
Can it be done? Yes, but you may experience problems with your FP extensions. It's a 'use at your own risk' type of deal. Some users encounter problems while some do not.

robfleming
2-3-04, 12:43 PM
Is there any explanation why some users have problems while others do not? Is it in the implementation of the changes described, or inherent in the extensions?

I tried following the PowWeb help section instructions and it resulted in my website becoming totally inaccessible until I went back to OPS and reset the FP extensions.

Is there an alternative method, with an FP-developed website, to point to a subdomain? If not, it would appear I wasted $25 having the subdomain added to my package.

B&T
2-3-04, 04:06 PM
Alternatives to using htaccess. You could use javascript or php in your index page to test the url and if it is the pointed domain redirect to another page.

Here is an example using javascript (you would pace this in the head of your html page):

<script type="text/javascript">
URLName = top.location.host;
if (URLName=="www.seconddomain.com" || URLName=="seconddomain.com") {
self.location.replace("http://www.seconddomain.com/other.htm");
}
</script>

Using php you would test the variable $_SERVER['HTTP_HOST'] for the domain name.

robfleming
2-3-04, 04:38 PM
You're being very helpful, B&T. But, I'm not a coder and almost totally unfamiliar with php. Let me make my need as clear as possible:

I have a main domain, mettlerelectronics.com, and a subdomain, mettlersurgical.com. My multi-page website is at the main domain URL, but I have one page "site" (for now) I'd like people to see if they enter "mettlersurgical.com" in their address bar.

I created a new subfolder, "me800" inside the htdocs folder as instructed by PowWeb help, and loaded it with the target files. Then I modified the .htaccess as directed, saved the modified file to htdocs and discovered later that only the part I added actually made the transfer and the FP extension part disappeared, rendering the website inaccessible. (I reloaded FP extensions in the PowWeb OPS area and got back to where I started.)

Other than getting into this business in the first place, what did I do wrong?

Thanks,

B&T
2-3-04, 05:53 PM
Where you went wrong was using FrontPage to upload your website. If you use FrontPage to develop your website, then just upload the needed pages using ftp, then FP will not be using your htaccess file.

But . . . given you are doing what you are doing, try this:

Put this code in the head section of your default index page (you can do that in html view in FP):

<script type="text/javascript">
URLName = top.location.host;
if (URLName=="www.mettlersurgical.com" || URLName=="mettlersurgical.com") {
self.location.replace("http://www.mettlersurgical.com/surgical.htm");
}
</script>

Then take your one page site and call it surgical.htm (in my example) in htdocs (no subdirectory needed). That should work for you.

When people put in www.mettlersurgical.com they will be directed to surgical.htm and the address bar will change to show www.mettlersurgical.com/surgical.htm (putting the page name on the end of the url). It will work with or without the www. the way it is coded.

That is the javascript method, which would probably be easiet for you to implement.

robfleming
2-3-04, 06:23 PM
Thank you for your patient and helpful response.

I may have uploaded my site with FP Publish, but is it too late to change to FTP? To change the .htaccess file I downloaded and used WS_FTP Pro and could easily use that to upload "needed" site pages if that would be better.

Thanks again.

robfleming
2-3-04, 06:32 PM
B&T - It worked!!!

Thank you very much. I appreciate your help and patience, and I learned something today, thanks to you.

B&T
2-3-04, 07:44 PM
Glad to help.

About 10% of the people on the net (or so they say - I bet it is much lower) have javascript disabled. For those people, this solution will not work.

If you convert to a php solution, you could get everyone. But then you would have more FP issues.