Forums

Managing redirects with .htpasswd active (4 posts)

  1. sennomo
    Member
    Posted 6 months ago #

    Hi,
    I have wp installed on http://www.domain.com/wp and have my site address set as http://www.domain.com. I followed a guide and set-up a redirect so users who go to http://www.domain.com go straight to the wp site.

    The problem is, I have password protected my root directory with .htaccess and .htpasswd, and if a user tries to login with http://domain.com (minus the www), the login is thrown back, and the site redirects to http://www.domain.com showing the login screen again.

    I would like it so that wp recognises both http://www.domain.com and http://domain.com as correct site addresses. Is this possible to fix?

    Thanks.

  2. ChristiNi
    Member
    Posted 6 months ago #

    Hi sennomo,

    Adding the following to your .htaccess file will force non-www over www. Add this just after the line RewriteEngine On:

    RewriteCond %{HTTP_HOST} ^yourdomain.com
    RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]

    Hope this helps!

  3. sennomo
    Member
    Posted 6 months ago #

    Thanks ChristiNi,
    I've had very little experience with Apache modules, so I've been reading up on the two mentioned here. I also noticed I didn't have the RewriteEngine On: line in my .htaccess, so I googled that and found I might need to add a couple more lines before that too :P

    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^domain.fi
    RewriteRule (.*) http://www.domain.fi/$1 [R=301,L]

    So, I'm not sure if those other lines were needed, but everything seems to be working now.

    Thanks again :)

  4. ChristiNi
    Member
    Posted 6 months ago #

    Hi sennomo,

    Glad to hear you got that sorted out. I thought you already had the RewriteEngine On since you had already set up a redirect. Options +FollowSymLinks isn't always needed explicitly in the .htaccess file. If your redirects work without Options +FollowSymLinks then your server is already setup with those enabled.

Reply

You must log in to post.

About this Topic