• pcmt

    (@pcmt)


    Could someone please explain how to alter the .htaccess file to force a trailing slash on the end of permalink WordPress page URLs that use the page slug? (eg ww*.domain.com/page-slug/) Yahoo is indexing all default page URLs, that are linked to with a trailing slash, without the trailing slash (eg ww*.domain.com/page-slug).

    This means that someone who finds a WordPress page in Yahoo and decides to link to it could do so without the trailing slash. Then if Google follows that link it will likely index both versions – I am seeing this happening and it is not a good thing.

Viewing 3 replies - 1 through 3 (of 3 total)
  • higher-logic

    (@higher-logic)

    Ok, this is really late, but I might as well answer it. Add the following to your .htaccess file:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ https://domain.com/$1/ [QSA,L,R=301]

    h8dk97

    (@h8dk97)

    I was looking for something like this as well. Thanks.

    What about redirecting from www to non-www domain?

    h8dk97

    (@h8dk97)

    How would you change this rule so that it doesn’t apply to files with .html extension?

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ https://domain.com/$1/ [QSA,L,R=301]

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Force trailing slash onto WordPress Page URLs’ is closed to new replies.