• Resolved pixelnate

    (@pixelnate)


    I am using the Quick Redirects plugin to set up page redirects, and, while that works brilliantly, I still am having some issues with redirects. Please understand, this is an .htaccess question and not a question about the plugin.

    Here is the situation. When we set up the redirects, the ones without a trailing slash do not get redirected. For example http://domain.com/something doesn’t get redirected, but http://domain.com/something/ (notice the trailing slash) does get redirected properly. Now, I have searched up and down on the interwebs, and while there is tons of info about regular expressions, mod_rewrite and .htaccess, I have yet to find anything WordPress-centric that helps me. So I am asking the community, how can I force a trailing slash on non-slash domains?

    Here is the relevant portion of my .htacess file:

    ### Uploaded files
    RewriteRule ^(.*/)?files/$ index.php [L]
    RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
    #RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]
    RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]
    
    ### Add a trailing slash to /wp-admin
    RewriteCond %{REQUEST_URI} ^.*/wp-admin$
    RewriteRule ^(.+)$ $1/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule . - [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    Any insight into this would be greatly appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Please don’t bump your posts.

    Really this is a problem with your plugin not making redirects correctly, but the basic would be to do this:

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

    Now I don’t know if WP will override that, but I would put that ABOVE the WordPress part of your htaccess and see if it helps.

    Thread Starter pixelnate

    (@pixelnate)

    I could kiss you, you sexy half-elf support rogue. It works brilliantly!

    – Wannabe Knight Elf Mohawk

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How can I force WP to add a trailling sliash in htaccess?’ is closed to new replies.