簡體   English   中英

想要阻止子目錄顯示在網址中

[英]Want to stop subdirectory from showing in urls

我已經閱讀了很多有關此主題的主題,但是我對這方面的知識不是很精通,對我來說沒有任何幫助。

我將Wordpress安裝在一個子目錄中,並且:

  1. 將站點地址URL更改為WordPress中的主域。
  2. 然后,我將.htaccessindex.php復制到根目錄。
  3. 然后,我更改了index.php文件,以便require('wp / wp-blog-header.php')指向子目錄。

一切正常,除了子目錄顯示在URL中,我想隱藏它。

我安裝到的子目錄是“ NA20H”。 index.php文件更改為指向它之后,這就是我所擁有的。

根目錄中的.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>

子目錄中的.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>

為了使“ NA20H”停止在URL中顯示,我需要怎么做? 謝謝。

無需將index.php復制到root。 只需按照以下步驟。 將其放在根目錄的.htaccess中。

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

將其放在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