Trailing slash at end of URL wordpress

2019-07-30 04:49发布

Dears,

I want to add / at the end of each url of site, below is what i found online, it works good, but in wp-admin it gives me wp-admin/index.php/index.php/. Like everytime i click on dashboard it will add /index.php/

code from htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]
</IfModule>

Please advise.

Thanks

1条回答
Lonely孤独者°
2楼-- · 2019-07-30 05:41

Keep redirect rule before your default WP rule:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI}/ [L,R=301,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Make sure to use a new browser for your testing.

查看更多
登录 后发表回答