简体   繁体   English

想要阻止子目录显示在网址中

[英]Want to stop subdirectory from showing in urls

I've read a lot of threads on this topic, but I'm not very proficient at this stuff and nothing has worked for me. 我已经阅读了很多有关此主题的主题,但是我对这方面的知识不是很精通,对我来说没有任何帮助。

I installed Wordpress in a sub directory and: 我将Wordpress安装在一个子目录中,并且:

  1. Changed the site address URL to the main domain in WordPress. 将站点地址URL更改为WordPress中的主域。
  2. Then I copied the .htaccess and index.php to the root directory. 然后,我将.htaccessindex.php复制到根目录。
  3. Then I changed the index.php file so that the require('wp/wp-blog-header.php') pointed to the subdirectory. 然后,我更改了index.php文件,以便require('wp / wp-blog-header.php')指向子目录。

Everything works, except the subdirectory shows in the URL, which I would like to hide. 一切正常,除了子目录显示在URL中,我想隐藏它。

The subdirectory I installed to is 'NA20H'. 我安装到的子目录是“ NA20H”。 After changing the index.php file to point to it, this is what I have. index.php文件更改为指向它之后,这就是我所拥有的。

The .htaccess file in the Root directory reads: 根目录中的.htaccess文件显示为:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /NA20H/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /NA20H/index.php [L]
</IfModule>

And the .htaccess in the subdirectory reads: 子目录中的.htaccess读取为:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /NA20H/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /NA20H/index.php [L]
</IfModule>

What do I need to do in order to get 'NA20H' to stop showing in the URLs? 为了使“ NA20H”停止在URL中显示,我需要怎么做? Thank you. 谢谢。

No need to copy index.php to root. 无需将index.php复制到root。 Just follow these steps. 只需按照以下步骤。 Put this in the .htaccess in the root. 将其放在根目录的.htaccess中。

RewriteEngine On
RewriteBase /
RewriteRule ^$ NA20H/ [L]
RewriteRule ^(.*)$ NA20H/$1 [L]

Put this in .htaccess in the NA20H folder 将其放在NA20H文件夹中的.htaccess中

RewriteEngine On
RewriteBase /NA20H/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM