【问题标题】:Remove subfolder name from url in wordpress as a subdomain从wordpress中的url中删除子文件夹名称作为子域
【发布时间】:2015-07-17 18:51:03
【问题描述】:

这是交易...在共享主机中,我创建了一个像 blog.mydomain.com 这样的子域来安装 wordpress,当我在 cpanel 中这样做时,它在根目录中创建了一个子文件夹,如 public/blog。 所以安装很顺利,但是当我访问 blog.mydomain url 时,它变为 blog.mydomain.com/blog 我想删除最后一个 /blog,它也显示找不到页面,但不像不存在的帖子那样显示为错误。

在 wordpress 的 codex 页面中,它说要做的第一件事是转到仪表板 > 常规面板并更改 WordPress 地址 (URL) 框 站点地址框(URL) 但在我的常规面板设置中,此选项未显示,我相信这是安装过程中出现的问题。

我猜我可以通过 .htaccess 完成此操作,顺便说一句,这是 wordpress 创建的:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

我必须修改这个 .htaccess 吗?如果是这样,该怎么做?或根文件夹中的那个,考虑到根是用于驻留在主域中的 laravel 应用程序。

这是主要的.htaccess

<IfModule mod_rewrite.c>
#LARAVEL
    Options -MultiViews
    RewriteEngine On

    RewriteRule ^(.*)/$ /$1 [L,R=301]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
#END LARAVEL

</IfModule>

希望有人能帮助我,谢谢...

【问题讨论】:

    标签: php wordpress .htaccess


    【解决方案1】:

    1)登录到您网站的管理员并将网站网址更新为

     blog.mydomain.com 
    

    2)打开根目录下的wp-config.php文件,找到

    define('WP_HOME','http://example.com');
    define('WP_SITEURL','http://example.com');
    

    并进行更改并更新主题文件夹中的functions.php文件。

    3) 更新数据库中 wp_options 表中的网站 url。

    【讨论】:

      【解决方案2】:

      第 1 步 打开根目录下的wp-config.php文件,找到

      define('WP_HOME','http://blog.mydomain.com/blog'); 定义('WP_SITEURL','http://blog.mydomain.com');

      第 2 步 将新子目录中的“index.php”和“.htaccess”文件复制到根目录中。

      第 3 步 使用文本编辑器打开根目录下的“index.php”文件。查找显示以下内容的行: 要求('./wp-blog-header.php'); 用此行替换该行: 要求('./blog/wp-blog-header.php');

      第 4 步 打开您的 Web 浏览器到以下地址站点 url blog.mydomain.com 管理网址是 blog.mydomain.com/blog/wp-admin

      【讨论】:

        猜你喜欢
        • 2016-09-17
        • 2014-04-13
        • 2014-04-22
        • 2015-08-02
        • 2019-07-04
        • 2017-10-18
        • 2016-10-16
        • 1970-01-01
        • 2023-04-10
        相关资源
        最近更新 更多