1

When I test a website in my local installation of Apache I always have /mysite.com/<site files> as the path. When the site gets deployed the root path will be just /.

Because I need to use absolute referencing I have to use /mysite.com/files on localhost and then change it everywhere for the remote server to simply /.

How can I please do that better? Can I set something in .htaccess for this?

1 Answer 1

1

Put this in your .htaccess (in /):
RewriteEngine On
RewriteRule ^/mysite.com/(.*)$ http://yourwebsite.com/$1 [R=301]

If that doesn't work, replace the ^/mysite with ^mysite (I can't remember offhand where it starts matching).

4
  • Hi, thanks for the reply. I'm not sure I was clear. What I want is for my local installation of Apache, when accessing: localhost/mysite which normally has this absolute path /mysite/ to set the root for localhost/mysite.com to be simply /, in order to match how it will be when deploied.
    – Francisc
    Nov 8, 2010 at 22:57
  • Can you give a more specific example? Is it the DocumentRoot (ie. where abouts on the server the files are stored) that needs changing? If so, change this inside Apache or rewrite them as above. If not, I'm not sure I understand
    – James L
    Nov 9, 2010 at 0:51
  • Ok, I want to have the root set to /mysite/ for localhost/mysite.
    – Francisc
    Nov 9, 2010 at 11:22
  • For /mysite/index.php if I want to load this image I have to use /mysite/img.jpg. However what I want is to point to the image when the call is made from /mysite/index.php like this /img.jpg as if it would be in the root. I want for /mysite/index.php to have the root inside /mysite/.
    – Francisc
    Nov 9, 2010 at 11:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .