我有2个网站
我是单个域,例如http://www.shopnow.com/,所以我需要在根目录中设置.htaccess
文件,以便
我已在根文件夹中尝试.htaccess
# .htaccess main domain to subdirectory redirect
# Do not change this line.
RewriteEngine on
# Change example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?shopnow.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
#RewriteCond %{REQUEST_URI} !^/shopnow/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /shopnow/$1
# Change example.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.)?shopnow.com$
RewriteRule ^(/)?$ /shopnow/index.php [L]
答案 0 :(得分:0)
您必须更改Apache的站点配置。使用它编辑帖子,转到/etc/apache2/sites-enabled/
并查找您的文件。您需要做的是查找DocumentRoot
(如果您没有更改它应该说/var/www/html
)并将其更改为YOUR_HTML_ROOT/public_html/shop
然后复制并通过相同的文件,将指向其他站点的值更改为新的。
这是一个例子:000-shop.conf
<VirtualHost *:80>
ServerName shopnow.com
ServerAlias www.shopnow.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/public_html/shop
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
对于博客:001-blog.conf
<VirtualHost *:80>
ServerName blog.shopnow.com
ServerAlias www.blog.shopnow.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/public_html/blog
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
请记住,您必须修改DNS区域并添加指向您的域的CNAME
,使用@
并使用blog
作为值。另请记住,您必须编辑此文件以满足您的需求。