I'm working with a WordPress installation in a subdirectory. I'd like the front page URL to not have a trailing slash. I've already set the permalinks to not have any trailing slashes in the WordPress admin screen. However since this WordPress installation is in a subdirectory, the trailing slash was still appearing on the front page. So I worked with the .htaccess files in the root directory and the WordPress installation directory to try and get rid of it on the front page as well. It doesn't seem to be working and I think WordPress might be adding the trailing slash to the front page and redirecting somewhere within the PHP itself, perhaps in the /wp-includes/canonical.php
file. There are several lines in that file that specifically mention always adding a trailing slash to the front page -- yet I commented them out and the trailing slash is still showing up.
With the current setup:
- all of the pages in the WordPress installation except for the front page fail to load -- the 404 page in the root directory of the hosting is shown instead
/wordpressdirectory
redirects to/wordpressdirectory/
and shows the front page/wordpressdirectory/
doesn't redirect and also shows the front page/wordpressdirectory/index.php
redirects to/wordpressdirectory/
and also shows the front page
Here is what the .htaccess file in my root directory looks like:
Options -Indexes
DirectorySlash Off
RewriteEngine On
RewriteRule ^wordpressdirectory$ /wordpressdirectory/index.php [L,R=302,E=LOOP:1]
And the .htaccess file in the WordPress installation directory is now empty -- I got rid of all of the default RewriteRules that came with WordPress for now.
But just in case, here is what the .htaccess in the WordPress installation directory used to be (all default, with no personal edits yet):
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpressdirectory/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpressdirectory/index.php [L]
</IfModule>
# END WordPress