Linux Apache2 Wordpress核心在子目录中,但没有重定向到wp-admin

时间:2018-06-02 11:56:04

标签: php wordpress apache .htaccess

我当前的Wordpress安装位于/var/www/html/mydomain.tld/cms/,我的WP_SITEURL在wp-config.php中设置为https://mydomain.tld/cms,WP_HOME设置为https://mydomain.tld

/var/www/html/mydomain.tld/index.phprequire( dirname( __FILE__ ) . '/cms/wp-blog-header.php' ); /var/www/html/mydomain.tld/.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

/var/www/html/mydomain.tld/.htaccess为空 我的永久链接设置为&#34; day和name&#34;:https://mydomain.tld/2018/06/02/sample-post/

目前的行为是,我可以使用https://mydomain.tld进行浏览,而像https://mydomain.tld/about这样的网页可以毫无问题地工作。

问题在于我将wordpress安装放在子目录中以确保https://mydomain.tld/wp-admin将返回404.但是现在它返回302指向https://mydomain.tld/cms/wp-admin,有效地将任何攻击者重定向到正确的位置

如何配置wordpress和/或Apache2以按预期方式运行?

1 个答案:

答案 0 :(得分:0)

如果你有mod_alias,你可以

重定向404 / wp-admin /

就像在那个网址上扔404一样

取自https://webmasters.stackexchange.com/questions/42822/how-to-redirect-specific-url-to-404-in-htaccess

我还没有尝试过。