开发者

Remove the path part to access my website

I got a rather easy problem. How do I remove the path to my website called domain.com?

I've got a lampp server where I put one folder called "domain" in the htdocs folder and to access my website I need to write domain.com/domain instead of just domain.com. And when I write domain.com I come to the usual xampp w开发者_C百科ebsite


There are a few options, but the easiest is probably using some URL rewriting given your current setup.

mod_rewrite in .htaccess

In your htdocs folder create a .htaccess file:

RewriteEngine On
RewriteBase /
# If the URL does not already exist as a file
RewriteCond %{REQUEST_FILENAME} !-f
# or directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /domain/$1 [QSA,L,NC]

Virtual hosting with Apache

You could also edit your VirtualHost container in the Apache configuration to change the directory as well. If you are running XAMPP then I have previously written about using virtual hosts with it on my blog.

For example:

<VirtualHost *:80>
    ServerAdmin name@domain.com
    DocumentRoot c:\xampp\simonholywell.com\pub
    ServerName simonholywell.localhost
    <Directory c:\xampp\simonholywell.com\pub>
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

A development server for teams (or individuals)

I have also written a large article on setting up a development or staging server for a team as well, which would be good reading if you are setting up such a system. It allows you to simply add a folder on the server and it is immediately available as a subdomain without any further configuration. This is something called mass virtual hosting.


You need to add a virtual host, check the apache name based virtual host documentation. If you're running on windows you could follow this guide, if you're on linux/unix you could try the following guide

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜