【问题标题】:.htaccess configuration for homepage of wordpress site to a subdirectory and other pages to root directory.htaccess 配置 wordpress 网站主页到子目录和其他页面到根目录
【发布时间】:2018-08-27 13:22:12
【问题描述】:
我目前有一个 wordpress 网站。我已经在一个新的 wordpress 安装上重新编码了新主页,该安装位于实时服务器上的 main 文件夹下。
我需要 .htaccess 配置,它将主页映射到新主页,无需 url 重定向到子文件夹,其他页面将保持不变。
例如。当我打开 example.com 时,主文件夹下的新 wordpress 站点的内容应该可见,其他页面例如。 example.com/about-us 将显示当前直播站点根目录下的内容。
【问题讨论】:
标签:
php
wordpress
.htaccess
subdirectory
【解决方案1】:
我在 hostgator 中使用了这个。注意:latinstartup.com 是帐户的主域。这是位于 public_html 文件夹中的 .htaccess 的代码。祝你好运!
# Use PHP56
AddHandler application/x-httpd-php56 .php
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.
# Do not change this line.
RewriteEngine on
# Change exampledomain.com to be your primary domain.
RewriteCond %{HTTP_HOST} ^(www.)?latinstartup.com$
# Change ‘subfolder’ to be the folder you will use for your primary domain.
RewriteCond %{REQUEST_URI} !^/latinstartup/
# Don’t change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change ‘subfolder’ to be the folder you will use for your primary domain.
RewriteRule ^(.*)$ /latinstartup/$1
# Change exampledomain.com to be your primary domain again.
# Change ‘subfolder’ to be the folder you will use for your primary domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?latinstartup.com$
RewriteRule ^(/)?$ latinstartup/index.php [L]