Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2006-05-06 13:48:10
- TheUsability
- Member
- Registered: 2005-05-03
- Posts: 51
Redirect Troubles
Hi,
I use this .htaccess in my web root to redirect all calls to “www.mysite.com” to “mysite.com” (don’t ask me why, I just like it that way):
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.mysite\.com$
RewriteRule (.*) http://mysite.com/$1 [R=Permanent]
This RewriteRule normally makes it also possible to redirect “www.mysite.com/somedir” to “mysite.com/somedir”. It doesn’t work with my TXP directory, though.
You see, I got my blog at “mysite.com/blog”. When entering “www.mysite.com/blog” it doesn’t get redirected to “mysite.com/blog”, though, it just stays at “www.mysite.com/blog”.
I would venture a guess that it’s because of the Rewrite rules in TXP’s .htaccess. Now my question: How do I change TXP’s .htaccess so that “www.mysite.com/blog” gets redirected to “mysite.com/blog” also, including subdirectories like “mysite.com/blog/category”? (I’m not much of a mod_rewrite expert, I have to admit.)
Cheers,
_TU
Last edited by TheUsability (2006-05-06 13:55:58)
Offline
#2 2006-05-06 15:26:20
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Redirect Troubles
I’d try adding those two lines as they are to the textpattern .htaccess (after RewriteEngine On, and not the RewriteBase /).
Offline
#3 2006-05-06 15:39:20
- TheUsability
- Member
- Registered: 2005-05-03
- Posts: 51
Re: Redirect Troubles
I’m getting a Server Error 500 if I do this. My current TXP .htaccess (in mysite.com/blog) looks like this:
*
<code>
#DirectoryIndex index.php index.html
#Options +FollowSymLinks
#RewriteBase /relative/web/path/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) – [PT,L]
RewriteRule ^(.*) index.php
</IfModule>
#php_value register_globals 0
</code>
*
I inserted the two lines
RewriteCond %{HTTP_HOST} ^www\.mysite\.com$
RewriteRule (.*) http://mysite.com/$1 [R=Permanent]
after “RewriteEngine On” one time and one time after “RewriteRule ^(.*) index.php” – both let to Server Errors.
Any idea why that is?
_TU
Last edited by TheUsability (2006-05-06 15:44:47)
Offline
#4 2006-05-06 16:39:43
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Redirect Troubles
TheUsability wrote:
Any idea why that is?
Er… no. Sorry, my way of finding out what to add and where is just trial and error. But most of the time eventually I get somewhere ;)
So I’ve been trying a few things, but unfortunately this time none of them seem to work. Hopefully someone wiser than me will be able to answer your question.
Offline
#5 2006-05-06 19:24:42
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Redirect Troubles
#DirectoryIndex index.php index.html
#Options +FollowSymLinks
#RewriteBase /relative/web/path/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.mysite\.com$ [NC]
RewriteRule ^(.*)$ http://mysite.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.php
</IfModule>
#php_value register_globals 0
:)
Last edited by Mary (2006-05-06 19:24:55)
Offline
#6 2006-05-06 19:36:48
- TheUsability
- Member
- Registered: 2005-05-03
- Posts: 51
Re: Redirect Troubles
@Mary: www.mysite.com/blog is now rewritten to mysite.com/blog which is nice. All my article urls get a 404 now, though.
I’m using the section/id variant.
Offline
#7 2006-05-06 20:02:24
- TheUsability
- Member
- Registered: 2005-05-03
- Posts: 51
Re: Redirect Troubles
BTW: It’s totally messed up – when I just add the two lines you describe to my current .htaccess, I get a 500 error, when I copy the whole stuff from your post, it seems to work and produces the above mentioned 404s.
Could that be? I mean, that .htaccess is this “sensible”?!
Cheers,
Ben
Offline
#8 2006-05-06 20:15:28
- TheUsability
- Member
- Registered: 2005-05-03
- Posts: 51
Re: Redirect Troubles
I just checked, my ftp client transfered .htaccess as a binary – stupid thing.
Anyway, the 404s (and 500s for that matter) are gone, though “www.mysite.com/blog” now redirects to “mysite.com” (and “www.mysite.com/blog/category” to “mysite.com/category”).
Cheers,
_TU
Last edited by TheUsability (2006-05-06 20:23:40)
Offline
Pages: 1