网站优化

网站优化

Products

当前位置:首页 > 网站优化 >

Wordpress多个子安装 - htaccess / index.php

GG网络技术分享 2025-03-18 16:12 4


问题描述:

I have two wordpress installations - each in their own directory - on my one main domain. like mydomain.com/site1 and mydomain.com/site2

By default when visiting mydomain.com it redirects to mydomain.com/site1

I am unsure where this redirect is coming from. There is no .htaccess file in the root of the main domain mydomain.com nor any Index.php file in the root of the main domain.

I have also checked both .htaccess files of each directory installation mydomain.com/site1 and mydomain.com/site2 and do not seem to find what is causing the main domain mydomain.com to redirect to mydomain.com/site1

My main goal is to change the main domain mydomain.com to redirect to mydomain.com/site2 by default

The contents of each .htaccess are as follows:

Site 1 .htaccess

# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /site1/

RewriteRule ^index\\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /site1/index.php [L]

</IfModule>

# END WordPress

# BEGIN wtfdivi

# END wtfdivi

Site 2 .htaccess

# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /site2/

RewriteRule ^index\\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /site2/index.php [L]

</IfModule>

# END WordPress

# BEGIN wtfdivi

# END wtfdivi

The contents of both directories Index.php (mydomain.com/site1 and mydomain.com/site2 )are identical as follows

<?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\' );

网友观点:

So, Now you can set your redirect url from phpmyadmin.

  1. Go to your database and find the wp_options table.

  2. Now edit the siteurl column and set your domain url here you want to reditect.

  3. Then edit the 2nd column home for your home page and set the same url.

Please clear the cache or press Ctrl+Shift+R or check it from the new incoming window.

标签:

提交需求或反馈

Demand feedback