user812120
user812120

Reputation: 585

WordPress Trailing Slash

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.

Upvotes: 3

Views: 8260

Answers (3)

Gufran Hasan
Gufran Hasan

Reputation: 9373

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]

Upvotes: 2

Ravi Patel
Ravi Patel

Reputation: 5211

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

Upvotes: 4

Maxim Sarandi
Maxim Sarandi

Reputation: 653

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

Upvotes: 0

Related Questions