Forum Moderators: phranque
I access the site using:
http://SERVER-IP/~account/
The problem is that the website (as far as the client side HTML/CSS is concerned) is contained within an /~account/ subdirectory, so my absolute paths in my CSS/HTML are now 1 directory too high up the tree. This is particulary effecting my CSS:
background-image:url(/img/banner.jpg);
This would work fine if the proper domain name was being used, but not with the SERVER-IP/~account/ format. As a result I am not seeing my background images!
It is tricky to avoid absolute paths in the CSS file if the CSS file is used throughout the site, from files at different levels in the tree.
How do I reliably test the site without the domain name?
Is there any work-around for this? Use of .htaccess perhaps? I assume this is an Apache server issue?
Any help greatly appreciated, cheers.
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim
Specifically I want to test a site move before point my domain to it. The test url root is myhost.com/~mysite. The problem if I understand it right is the tilde (~). The root resolves to the host.
I'm very new to mod_rewrite, but willing to learn. I've read many tutorials to try to solve this.
My question (forgive me if this is too obvious for you) is if I can really rewrite a URL request, if the server believes the root is myhost.com. When I place the the .htaccess in myhost.com/~mysite - does it even see it? I realize if I had better understanding of mod_rewrite I would probably know the answer, but it is overwhelming to understand when starting from scratch.
I tried replacing "/" with "/~mysite" with no effect. I learned later that you can only do that in the httpd.conf, not in .htaccess (which makes sense).
If someone can point to a post or article that deals with this (specifically for testing sites with root-relative links), it would be *greatly* appreciated!
Since domain names are inexpensive these days, it works. My host allows for extra "domain pointers" to use additional domains at no charge, which I can set up myself.
Once the real domain name resolves to the site, I can use the subdomain idea for testing, using a subfolder as a test root.
I gave up trying to redirect or change to root directory. As far as I can tell, on a shared server I have no way to do this.
Regarding mod_rewrite, I wrote
I tried replacing "/" with "/~mysite" with no effect.
replacing "/" with "/~mysite/"though I actually tried both to no avail, because as Jim pointed out, the htaccess would have to go in the "root directory" which I can't get to.
I supposed the problem was the tilde (~) in the path, but more correctly, I guess until a domain name resolves to my account, my files are seen to be in a subfolder of the host. (myhost.com/~mysite)
By the same token, a subdomain is not effective until I actually have a domain.
Thanks for the tips. Hope this helps someone.
When you want to go to the old site, you can simply comment that line out of your hosts file. No restart or reboot required.
If you have clients who need to view the site on the new server, though, that's not such a good solution, because clients (at least mine) are generally not capable of editing their hosts file.