php - Add trailing slash to domain name

494

Good afternoon!

I need add trailing slash to domain name. For example: fromhttp://www.domain.com tohttp://www.domain.com/. I try to add settings to .htaccess:

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

but Wordpress trims trailing slash only in domain name, other addresses work fine:http://www.domain.com/dir -http://www.domain.com/dir/

Best regards, Deifinger!

370

Answer

Solution:

http://domain.com/ 

is equivalent to

http://domain.com  

you cannot redirect your url from:

http://www.domain.com 

to

http://www.domain.com/ 

People are also looking for solutions to the problem: php - Flatten multidimensional array to 3 levels preserving the first level keys

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.