是否完全屏蔽WordPress安装子目录的*所有*痕迹?

时间:2015-01-11 作者:NewBee

从中可以看出dem0site.net (已安装到自己的子目录(public_html/wp-org-01/), 我已经成功地遵循了Codex的说明"giving WordPress its own directory" (using a pre-existing subdirectory install).

网站的外部可见URL已从http://dem0site.net/wp-org-01 简单地http://dem0site.net. 个人帖子的“漂亮的永久链接”也以我希望的方式出现——例如:http://dem0site.net/hello-world/.

然而,我想摆脱all \'wp-org-01/\' 安装子目录,仍然显示:

将鼠标悬停在\'Site Admin\' “Meta”小部件的元素,其中显示:http://dem0site.net/wp-org-01/wp-login.php

  • 用于\'uploads\' 目录,例如http://dem0site.net/wp-org-01/wp-content/uploads/2015/01/WordPressOrgIcon1.png.
  • 是否可以fully 使用just\'屏蔽安装子目录的所有这些外部跟踪。htaccess和标准WordPress设置,但不依赖任何插件?

    1 个回复
    最合适的回答,由SO网友:NewBee 整理而成

    为了对这个问题的答案感兴趣的人,我在这里发布了我在WordPress.org support forums.

    leejosepho 优雅地回答如下:

    是的,这是可能的。保存\'http://dem0site.net\' 在Dashboard>Settings>General(仪表板>设置>常规)的两个框中,cPanel将您的域分配并-指向public\\u html,并使用此htaccess将其重定向到“wp-org-01”(或任何位置):

    # .htaccess main domain to subdirectory redirect
    # Do not change this line.
    RewriteEngine on
    # Change example.com to be your main domain.
    RewriteCond %{HTTP_HOST} ^(www.)?example.com$
    # Change \'subdirectory\' to be the directory you will use for your main domain.
    RewriteCond %{REQUEST_URI} !^/subdirectory/
    # Don\'t change the following two lines.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # Change \'subdirectory\' to be the directory you will use for your main domain.
    RewriteRule ^(.*)$ /subdirectory/$1
    # Change example.com to be your main domain again.
    # Change \'subdirectory\' to be the directory you will use for your main domain
    # followed by / then the main file for your site, index.php, index.html, etc.
    RewriteCond %{HTTP_HOST} ^(www.)?example.com$
    #RewriteRule ^(/)?$ subdirectory/index.html [L]
    ## index.php for WordPress
    RewriteRule ^(/)?$ subdirectory/index.php [L]
    
    访问您网站的访问者将无法判断您的主域正在使用子目录,他们仍会看到网站地址http://www.example.com/... https://my.bluehost.com/cgi/help/347#redirect

    结束

    相关推荐

    强化WordPress:使用htaccess阻止/包含

    此页https://wordpress.org/support/article/hardening-wordpress/表示这应该包含在中。htaccess file阻止对includes目录中文件的请求。# Block the include-only files. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^wp-admin/includes/ - [F,L]&#x