首页 > php开发, 技术学习 > 如何配置apache使域名直接指向根目录下面的文件夹

如何配置apache使域名直接指向根目录下面的文件夹

如何配置apache使域名直接指向根目录下面的文件夹
针对linux的方案,因为要新建一个.htaccess文件

该文件中的内容是:

# Hostmonster.com
# .htaccess main domain to subdirectory redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.
# Do not change this line. RewriteEngine on
# Change yourdomain.com to be your main domain. RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
# Change ‘subdirectory’ to be the directory you will use for your main domain. RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don’t change this line. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d
# Change ‘subdirectory’ to be the directory you will use for your main domain. RewriteRule ^(.*)$ /subdirectory/$1
# Change yourdomain.com to be your main domain again.
# Change ‘subdirectory’ to be the directory you will use for your main domain # followed by / then the main file for your site, index.php, index.html, etc. RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$ RewriteRule ^(/)?$ subdirectory/index.php [L]
#开头的语句是注释,被apache服务器忽略。 # Do not change this line.#不要修改下面这行 RewriteEngine on # Change yourdomain.com to be your main domain.#把下面的yourdomain.com 修改为你自己的主域名 RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$ # Change ’subfolder’ to be the folder you will use for your main domain.#把下面的’subfolder’修改为你在主机上的子目录 RewriteCond %{REQUEST_URI} !^/subfolder/ # Don’t change this line.#不要修改下面2行 RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d # Change ’subdirectory’ to be the folder you will use for your main domain.#把下面的’subdirectory’修改为你在主机上的子目录 RewriteRule ^(.*)$ /subdirectory/$1 # Change yourdomain.com to be your main domain again.# Change ’subfolder’ to be the folder you will use for your main domain# followed by / then the main file for your site, index.php, index.html, etc.#把下面的yourdomain.com 修改为你自己的主域名#把下面的’subfolder’修改为你在主机上的子目录#把紧跟在/后面的index.php 换成你站点的主文件,如index.php, index.html等等。 RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$RewriteRule ^(/)?$ subfolder/index.php [L]

如何配置apache使域名直接指向根目录下面的文件夹 针对linux的方案,因为要新建一个.htaccess文 […]

  1. 还没有评论
评论提交中, 请稍候...

留言

(Spamcheck Enabled)

Trackbacks & Pingbacks ( 0 )
  1. 还没有 trackbacks