Forums

combine pretty perma and redirect (3 posts)

  1. boboz
    Member
    Posted 3 years ago #

    Hi,

    I have htaccess setup for pretty perma links and would lika to add code to redirect from http://www.domain.com to domain.com. How do I combine those rules?

    pretty perma links:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    redirect:

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

    Thanks, Bo

  2. terriann
    Member
    Posted 3 years ago #

    You should be able to use

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

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

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    Does that work for you?

  3. boboz
    Member
    Posted 3 years ago #

    Thanks terriann,

    As far as I can see it seems to work as it should.
    After some more reading I found the post below that says the URL settings under “general options” works the same way as a 301 in htaccess. So for now I'm running both ways.

    http://wordpress.org/support/topic/156533?replies=7

Topic Closed

This topic has been closed to new replies.

About this Topic