Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-12-02 17:59:26

fungi
Member
Registered: 2008-11-09
Posts: 16
Website

301 redirect issue

Hello Everyone. I’m having some trouble setting up my .htaccess file to redirect my WWW traffic to my non-WWW domain. Here is what my htaccess file currently looks like…

#DirectoryIndex index.php index.html

#Options +FollowSymLinks
#Options -Indexes

<IfModule mod_rewrite.c>

RewriteEngine On
#RewriteBase /relative/web/path/

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) – [PT,L]

RewriteRule ^(.*) index.php

RewriteCond %{HTTP:Authorization} !^$
RewriteRule .* – [E=REMOTE_USER:%{HTTP:Authorization}]

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

</IfModule>

#php_value register_globals 0

The only thing I added is the very last rewrite condition. The redirect is working but I get a 401 error. The redirect takes you to “http://jonwilliamsdesign.com/index.php/” and i’ve noticed that if only that last backslash after index.php was not there it would work fine. Does anyone know what is happening here and how I might fix it? Thanks.

Last edited by fungi (2008-12-02 18:03:58)

Offline

#2 2008-12-02 18:23:43

fungi
Member
Registered: 2008-11-09
Posts: 16
Website

Re: 301 redirect issue

Sorry, one more thing. I don’t see a section in the admin panel for changing the stylesheet associated with 401 error pages. How can I attach the correct style so that it matches the rest of my site? Thanks again to anyone who can offer some help.

Offline

#3 2008-12-02 19:33:49

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: 301 redirect issue

This should do it:

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

I think the error pages use the default style sheet. If you want to change that use this tag on the error page:

<txp:css format="link" n="name_of_stylesheet" />

Offline

#4 2008-12-02 19:43:43

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: 301 redirect issue

Also, (I think) those rewrite rules should be before the textpattern rewrite rules set.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#5 2008-12-02 19:48:38

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: 301 redirect issue

For me it works if I put it here:

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^(.+) - [PT,L]

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

 RewriteRule ^(.*) index.php
</IfModule>

Offline

#6 2008-12-02 21:59:57

fungi
Member
Registered: 2008-11-09
Posts: 16
Website

Re: 301 redirect issue

Thank you Els and maniqui, that did the trick after I made the slight changes and put the rewrite rules in the correct order. Cheers.

Offline

Board footer

Powered by FluxBB