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?

user9517
  • 115,471
  • 20
  • 215
  • 297
Francisc
  • 153
  • 1
  • 3
  • 11

1 Answers1

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).

James L
  • 6,025
  • 1
  • 22
  • 26
  • Hi, thanks for the reply. I'm not sure I was clear. What I want is for my local installation of Apache, when accessing: http://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 08 '10 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 09 '10 at 00:51
  • Ok, I want to have the root set to /mysite/ for http://localhost/mysite/. – Francisc Nov 09 '10 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 09 '10 at 11:24