子域重定向到主域

时间:2019-05-18 01:08:12

标签: apache .htaccess virtualhost

我目前有一个带有LAMP的Ubuntu盒子安装程序,并且已经安装了可以通过主域名example.com.au访问的Wordpress,它工作正常。我还为park.example.com.au创建了A记录,并在sites-available中添加了.conf文件,并运行a2ensite并重新启动了apache服务。

访问park.example.com.au时,我被重定向到example.com.au,但是,如果我访问park.example.com.au/index.html,则会看到虚拟索引文件(子站点不会是WordPress)。努力理解如何使这项工作有效,并且我阅读的所有示例似乎都与WP多站点有关,并且重定向是在WP中处理的。

我已根据其他问题调整了.htaccess文件,并在子域的文件夹中创建了一个单独的.htaccess文件。

Playground.conf

<VirtualHost *:80>


ServerAdmin webmaster@localhost
ServerName playground.example.com.au
ServerAlias www.playground.example.com.au
DocumentRoot /var/www/html/playground/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/playground/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined


RewriteEngine on
RewriteCond %{SERVER_NAME} =playground.example.com.au [OR]
RewriteCond %{SERVER_NAME} =www.playground.example.com.au
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} 
[END,NE,R=permanent]
</VirtualHost>

.htaccess用于主域

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

php_value upload_max_filesize 64M php_value post_max_size 128M php_value memory_limit 256M php_value max_execution_time 300 php_value max_input_time 300

END WordPress

我希望将park.example.com.au作为其自己的网站以静态html页面运行。

0 个答案:

没有答案