Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-02-25 21:23:52

immarabi
Member
Registered: 2008-04-29
Posts: 57

DNS lookup, Clean URL and mod_rewrite fails

Hello,

I recently upgraded my site to 4.0.8 and tried to fix my .htaccess file to rewrite all url’s to the site to be forced to be without www. However, it doesn’t work. When you visit the site with www it redirects you to the site without www and adds index.php at the end, which produces a 404 error.

I believe this error is related. I also have: Web Domain DNS lookup fails: www.mysite.com
Clean URL test failed

In the preferences tab I have it set as mysite.com without www as the site URL

and here is the .htaccess file

#DirectoryIndex index.php index.html

Options +FollowSymLinks
#Options -Indexes

<IfModule mod_rewrite.c> RewriteEngine On #RewriteBase /

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

RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^(.*) index.php

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

RewriteCond %{HTTP_HOST} ^www.mysite.com$ [NC]
RewriteRule ^(.*) http://mysite.com/$1 [R=301,NC]
RewriteRule ^(.+[^/])$ http://mysite.com/$1/ [L,R=301]
</IfModule>

#php_value register_globals 0

I would appreciate any help on this.

Last edited by immarabi (2009-02-25 21:24:58)

Offline

#2 2009-02-25 22:35:32

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

Re: DNS lookup, Clean URL and mod_rewrite fails

It should be like this:

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

I also have it before the part with RewriteRule ^(.*) index.php, but I don’t know if that is important.

Offline

#3 2009-02-26 13:17:37

immarabi
Member
Registered: 2008-04-29
Posts: 57

Re: DNS lookup, Clean URL and mod_rewrite fails

Thanks for the reply. However, I am running into the same problem. When I type in www.mysite.com it redirects me to mysite.com/index.php which displays a 404 error.

Offline

#4 2009-02-26 19:15:04

immarabi
Member
Registered: 2008-04-29
Posts: 57

Re: DNS lookup, Clean URL and mod_rewrite fails

I figured it out. Your code for the .htaccess was very useful. It didn’t work though when I put in underneath all the other mod_rewrite rules. When I made it the first rule in the list everything worked perfectly!

Thanks again!

Offline

Board footer

Powered by FluxBB