3

WordPress adds trailing slash to each url as per permalink settings.

/%postname%/

So if you browse www.mysite.com/about-us you will be redirected to www.mysite.com/about-us/

Is it possible to disable this redirect so that the page is served with and without the trailing slash.

user812120
  • 585
  • 1
  • 10
  • 21

3 Answers3

4

change permalink /%postname%/ to /%postname%

enter image description here

Right below the RewriteEngine On line, add:

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

Moreinfo htaccess code

Ravi Patel
  • 5,121
  • 2
  • 25
  • 44
  • Hi Ravi, Thanks for your reply, I can change it but then Wordpress will start redirecting urls the other way, i.e. urls with trailing slash will be redirected to urls without trailing slash. Clients wants both url to be viewable with and without trailing slash and no redirect – user812120 Feb 20 '18 at 09:35
2

You can update your .htaccess file with following rules.

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule (.+)/$ http://your_domain_name/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Gufran Hasan
  • 8,910
  • 7
  • 38
  • 51
0

You can change .htaccess rules, defined by WordPress. This topic might hepls you.

Maxim Sarandi
  • 643
  • 5
  • 10