I have a WordPress site and I made it in a folder like this:
site.com/new/
In the principal path I have nothing, so when I get access into an article, I see the URL like this:
site.com/new/article-1
I would like to hide the base path and see something like this:
site.com/article-1
The default htaccess is this
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /new/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /new/index.php [L]
</IfModule>
# END WordPress
Yes you can do this without needing of .htaccess
rules.
Just move index.php
and .htaccess
from new
folder to one level up (basically parent) directory.
Then open your index.php
file and modify this line:
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
to
require( dirname( __FILE__ ) . '/new/wp-blog-header.php' );
Notice the new/
folder? This will look for Wordpress core files inside that folder.
And your .htaccess
to this:
# 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
Just removed the new/
directory.
And thats it, visit site.com
.
One thing to notice when you visit site.com/new
you may see all the Wordpress directories/files listing. To avoid that create a .htaccess
file inside the new
folder and paste this content:
Options -Indexes
P.S: You need to modify your urls in database to work with new one.