【问题标题】:primary domain to subfolder without folder name in url主域到 url 中没有文件夹名称的子文件夹
【发布时间】:2017-10-18 17:56:26
【问题描述】:

我有 2 个网站

  1. 购物网站 (Magneto 1)
  2. 博客网站 (Laravel)

我有一个域,例如http://www.shopnow.com/,所以我需要在根目录中设置.htaccess 文件,以便

  1. http://www.shopnow.com ==> public_html/shop
  2. http://blog.shopnow.com ==> public_html/blog

我已经在根文件夹中尝试.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] 

【问题讨论】:

    标签: php .htaccess magento url-rewriting laravel-5.3


    【解决方案1】:

    您必须更改 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 作为值。另请记住,您必须编辑此文件以满足您的需要。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-03
      • 2022-01-17
      • 1970-01-01
      • 2013-04-14
      • 2016-12-17
      相关资源
      最近更新 更多