• kaspr

    (@kaspr)


    Is it possible to redirect all my wordpress pages to have a forward slash at the end of the url?

    Currently my pages can both end to have / and non / version. Which means it will duplicate the pages from search engines. Which, I believe, is not good.

    For example, I want this page
    http://www.example.com/contact-us

    to redirect to
    http://www.example.com/contact-us/

    I want that to all of my pages, how can i do that via .htaccess? Or is there any alternative way to do this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • ryscript

    (@ryansutana)

    Hi @kaspr yeah there is by using permalinks, change your permalinks to Custom Structure and paste /%postname%/

    Hope that helps.

    Thread Starter kaspr

    (@kaspr)

    i also tried using permalinks structure of /%postname%/ but it still doesn’t do what i expect it to do.

    Thread Starter kaspr

    (@kaspr)

    I tried adding new rules to my htaccess, from this

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    to have it like this.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{REQUEST_URI} !\.(php|html?|jpg|gif|png|css|js)$
    RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301]
    
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    It seems to make it work that that, however, after a while or after you cleared your browser’s cache. My wordpress pages returns to http://www.mydomain.com/404.shtml/

    Any ideas why is this occuring like this? Or is there something wrong with my htaccess?

    Thread Starter kaspr

    (@kaspr)

    no one really knows how?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘redirect all wordpress pages with ending forward slash .htaccess’ is closed to new replies.