我的主机root看起来像:
/
.htaccess
index.php
-wordpress1
--wp-content
--wp-include
--.htaccess
--index.php
--...etc...
-wordpress2
--wp-content
--wp-include
--.htaccess
--index.php
--...etc...
我首先在子目录 wordpress1 安装了一个wordpress,并使用主域指向它。
现在我要添加一个子域名,如 subdomain.domain.com ,子域名也是一个目录,指向子目录 wordpress2 ,我可以访问它使用 subdomain.domain.com
------ 1
我的根.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>
# END WordPress
我的root index.php
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wordpress1/wp-blog-header.php' );
------ 2
我的 wordpress1 .htaccess文件,如;
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress1/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpess1/index.php [L]
</IfModule>
# END WordPress
我的 wordpress1 index.php
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
----- 3
我的 wordpress2 .htaccess文件,如;
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress2/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpess2/index.php [L]
</IfModule>
# END WordPress
我的 wordpress2 index.php
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
现在我可以使用 maindmain.com 访问 wordpress1 ,而且我无法使用 wordpress1.maindomain.com 访问 wordpress2 ,但可以使用 maindomain.com/wordpress2 访问。
如何更改?
谢谢!