0

I had a lot of difficulties getting a domain of mine to point to a folder in my Wamp /www directory.

However, I'm now wanting to work on getting another domain working, but before that I'd like to work on the domain under localhost and edit it through there.

But, whenever I go to localhost or the Ip of the server on a browser, it goes to my domain.

I only want to go to that domain when I type the domains name, not when I type localhost on that machine or the IP on a different machine.

TL:Dr;

I want mywebsite.com > /www/mywebsite (this has already been done) I want localhost/ > /www (main folder)

Windows Server with WAMP

Here's my current htaccess to get the domain working with the folder (probably not an efficient way) Removed thanks to RiggsFolly

RewriteEngine On

RewriteCond %{HTTP_HOST}   (?:www\.)?mywebsite\.com  [NC]
RewriteCond %{REQUEST_URI} !^/mywebsite
RewriteRule ^(.*)$ /mywebsite/$1 [L]
RewriteRule ^(.*)$ http://mywebsite.comk/$1 [L,R=301]

After adding Virtual hosts

<VirtualHost *:80> 
    DocumentRoot "c:/wamp/www" 
    ServerName localhost 
    ServerAlias localhost 
    <Directory "c:/wamp/www"> 
        Options Indexes FollowSymLinks 
        AllowOverride All 
        Require local 
    </Directory> 
</VirtualHost> 

<VirtualHost *:80> 
    ServerAdmin info@mywebsite.com 
    DocumentRoot "c:/wamp/www/mywebsite" 
    ServerName mywebsite.com 
    ServerAlias www.mywebsite.com 
    ErrorLog "logs/mywebsite-error.log" 
    CustomLog "logs/mywebsite-access.log" common 
</VirtualHost> 

Still not working. localhost will load mywebsite.com (name changed for privacy). I want localhost to load the main directory not the mywebsite sub-directory!

Mark R
  • 1
  • 1
  • You need to create a virtual host for each domain you want to have within a single Apache instance. See [this post for help](http://stackoverflow.com/questions/23665064/project-links-do-not-work-on-wamp-server/23990618#23990618) – RiggsFolly Nov 11 '16 at 12:38
  • Thanks for the reply. I followed it from start to end, and whilst the site still works my problem is still prevelent. When I go to localhost on the machine, it'll take me to mywebsite.com/mywebsite as if localhost is being redirected to mywebsite.com and then it's looking for the folder in /www. How do I stop localhost becoming mywebsite.com? It seems like it's defined somewhere but in the DocumentRoot it's still set to the /www folder and not the /mywebsite/ one. – Mark R Nov 11 '16 at 17:02
  • Show your `httpd-vhosts.conf` file – RiggsFolly Nov 11 '16 at 17:03
  • DocumentRoot "c:/wamp/www" ServerName localhost ServerAlias localhost Options Indexes FollowSymLinks AllowOverride All Require local ServerAdmin info@mywebsite.com DocumentRoot "c:/wamp/www/mywebsite" ServerName mywebsite.com ServerAlias www.mywebsite.com ErrorLog "logs/mywebsite-error.log" CustomLog "logs/mywebsite-access.log" common http://pastebin.com/5Cf00rNp pastebin to make it easier to read. – Mark R Nov 11 '16 at 17:12
  • So what looks different about the second VH definition and the first????? – RiggsFolly Nov 11 '16 at 19:44
  • I'm guessing the part? I've added that in but it hasn't made a difference, localhost still goes to mywebsite VH. – Mark R Nov 11 '16 at 22:52
  • I take it you have removed the `htaccess` file(s) right – RiggsFolly Nov 12 '16 at 02:39
  • Yeah that's all removed no htaccess files in any of the directories anymore. – Mark R Nov 12 '16 at 04:25
  • Ok, wow-- simplest of fixes. Simply tried a new browser and bam localhost works. Cleared cache/cookies on my old browser and that worked too. Was using remote desktop to the server so changing browsers never really crossed my mind! Saying that though I've still got a problem. I've put a new VH up with my next project and when I go to that by either typing it in let's call it 'new website' or by clicking on it in the wamp homepage it takes me to my first/old site 'mywebsite'. What's going on!? Thanks for your continued help! – Mark R Nov 13 '16 at 03:49
  • Heheh, of course it was cached, you're going *permanent* redirects. – Walf Nov 13 '16 at 10:06
  • Ok, but how do I fix what I said above? – Mark R Nov 13 '16 at 16:07

0 Answers0