Bluehost.com Web Hosting $6.95

rewrite woes

This is a discussion on rewrite woes within the Apache Web Server forums, part of the Web Server and Related Forums category; I have a site (call it thesite.com) that I want always accessed as www.thesite.com, so I have ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-11-2006
Paul Lautman
 
Posts: n/a
Default rewrite woes

I have a site (call it thesite.com) that I want always accessed as
www.thesite.com, so I have been using the following rule:

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

So far so good. I also want to be able to use search engine friendly (SEF)
urls with the CMS on the site, so I just added.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php

BUT... I also have test installations of the CMS in subdirectories (e.g.
www.thesite.com/turnip, www.thesite.com/parsnip, ...)

Now since adding the SEF stuff, when I try to click onto a link in turnip,
it takes me to the main site in the root directory.

So I tried adding a new .htaccess file in the turnip directory thus:

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

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php

Which fixes the problem of being sent back to the root site, but it is also
losing the www off of the front of the urls if they are typed in the
browser. So when I enter www.thesite.com/turnip, is is ending up with
thesite.com/turnip in the browser.

Can anyone point me to what I need to do to:
1) enable my SEF urls
2) ensure all addresses in the browser have www. at the front
3) be able to access all the test installations in their subdirectories as
well as the main site in the root

I hope this is clear.

TIA
Regards
Paul Lautman


  #2 (permalink)  
Old 05-11-2006
Robert Ionescu
 
Posts: n/a
Default Re: rewrite woes

Paul Lautman wrote:
> RewriteCond %{HTTP_HOST} ^thesite\.com/turnip [nc]


The HTTP_HOST does not contain parts of the URL-path.

RewriteCond %{HTTP_HOST} ^thesite\.com

--
Robert
  #3 (permalink)  
Old 05-11-2006
Paul Lautman
 
Posts: n/a
Default Re: rewrite woes

Robert Ionescu wrote:
> Paul Lautman wrote:
>> RewriteCond %{HTTP_HOST} ^thesite\.com/turnip [nc]

>
> The HTTP_HOST does not contain parts of the URL-path.
>
> RewriteCond %{HTTP_HOST} ^thesite\.com


I didn't mention that I had only tried adding the /turnip in the RewriteCond
because it was not working without it.
But I discovered that the RewriteEngine On line was missing from the turnip
..htaccess. Here is what I have:

In root:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^thesite\.com [nc]
RewriteRule (.*) http://www.thesite.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php

In /turnip:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^thesite\.com
RewriteRule (.*) http://www.thesite.com/turnip/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php

It is working, but is there any way over this without having to have a
dedicated .htaccess file in each subdirectory?

TIA
Regards
Paul


  #4 (permalink)  
Old 05-14-2006
Robert Ionescu
 
Posts: n/a
Default Re: rewrite woes

Paul Lautman wrote:
> It is working, but is there any way over this without having to have a
> dedicated .htaccess file in each subdirectory?


It depends upon what you'd like to achieve. With your /turnip/.htaccess,
you're rewriting such requests to /turnip/index.php and not to /index.php

--
Robert
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:29 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0