简体   繁体   中英

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:

  1. Changed the site address URL to the main domain in WordPress.
  2. Then I copied the .htaccess and index.php to the root directory.
  3. Then I changed the index.php file so that the require('wp/wp-blog-header.php') pointed to the subdirectory.

Everything works, except the subdirectory shows in the URL, which I would like to hide.

The subdirectory I installed to is 'NA20H'. After changing the index.php file to point to it, this is what I have.

The .htaccess file in the Root directory reads:

<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:

<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? Thank you.

No need to copy index.php to root. Just follow these steps. Put this in the .htaccess in the root.

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

Put this in .htaccess in the NA20H folder

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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