0

I'm trying to remove the trailing slash from our URLs. I adjusted our .htaccess file and added this code:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

Unfortunately this didn't work as the pages (except for the homepage) suddenly show too many redirects and I get a message from the system saying "The page isn’t redirecting properly".

I was thinking maybe I made an error in the way I inserted the code. Originally, our .htaccess file has 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
# 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

After adjusting it to insert the code, it looked like this:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# BEGIN WordPress
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

And that resulted in an error. Can anybody point out where I went wrong? Thanks.

  • do you have any wordpress plugins or settings enforcing a slash? – Panama Jack Nov 21 '16 at 05:49
  • I'm not really sure. I saw another page on this issue that pointed to Yoast plugin as a possible culprit --- and we do have Yoast. But I checked its settings and can't find anything that refers to trailing slash in URLs – Sandy Albaytar Jr. Nov 21 '16 at 05:53

1 Answers1

0

Turns out it's a Wordpress issue. It's something you can adjust by going to your Wordpress site's Permalink Settings. From here you can choose your preferred URL format. "With-trailing-slash" is the default format so you definitely need to make an adjustment if you want the typical "without-trailing-slash" format.