I am having a tough time removing the subfolders from the URL in my WordPress site.
Currently, the URL format is:
www.mysite.com/subfolder/index.php/category/postname
I would like to remove both the subfolder AND index.php from the URL.
The site must stay in a subfolder of root on my server.
My current htaccess
file is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subfolder/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subfolder/index.php [L]
</IfModule>
I’ve tried to add the following, although it did not work.
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^subfolder/(.*)$ http://www.mysite.com/$1 [R=301,L]
RewriteRule .* index.php/$0 [PT,L]
You need to make the WP site url and home url differ in Settings / General. The home url should be
example.com
, while the site url (where WP lives) should beexample.com/wp
(or wherever you put it).You can hardcode these in your config file:
WP should know how to take things from there, and place the .htaccess where it should be.
In case it doesn’t, my own site’s folder looks like this:
The index.php file contains:
And the .htaccess contains:
Regarding the
/index.php
bit in URLs generated by WP, it means WP is (incorrectly?) finding that your site cannot manage permalinks. (Can I wager that this is because you’re using Nginx?)Assuming you know better than WP, add a must-use plugin in your wp-content/mu-plugins folder, e.g. a force-permalinks.php file:
Not sure what exactly you want. Can you please elaborate your question a bit more?
If you want URLs like
www.mysite.com/subfolder/postname
(where thesubfolder
is where your WordPress install is), then just go to Settings > Permalinks and change it to Post Name.EDIT
If your WordPress install is in
subfolder
and you want URLs likewww.mysite.com/category/postname
, then set both the WordPress Address and Site Address towww.mysite.com
and in Permalinks, choose Custom Structure and use this tag/%category%/%postname%
.