A simple problem

New to mod_rewrite? This is a good place to start.

A simple problem

Postby boggits » Thu Sep 11, 2003 5:47 am

What I'm trying to do:

I have a site that I'm trying to split into two over time, content in the /htdocs/www (root folder) /htdocs/www/assets/ and /htdocs/assets/images/ are staying on this server while the remainder is being moved onto www.domain2.com using the same structure..

What options I've written:

Code: Select all
        RewriteCond   /htdocs/www/%{REQUEST_FILENAME} !-f [NC]
        RewriteCond   /htdocs/www/assets/%{REQUEST_FILENAME} !-f [NC]
        RewriteCond   /htdocs/www/assets/images/%{REQUEST_FILENAME} !-f [NC]

        RewriteRule   ^(.+) http://www.domain2.com/$1


What this should do:

Check each directory for the file requested, if not their then go to new site

The Result:

No Matter what usrl I use I get redirected....
boggits
 
Posts: 2
Joined: Thu Sep 11, 2003 5:41 am

Postby pippo » Thu Sep 11, 2003 12:23 pm

Hi,
first of all
/htdocs/www/%{REQUEST_FILENAME}
/htdocs/www/assets/%{REQUEST_FILENAME}
/htdocs/www/assets/images/%{REQUEST_FILENAME}
is *not* correct, I know the documentation said so...

because for a document root as
/htdocs/www
and for a request as www.example.com/path/to/pippo.php

%{REQUEST_FILENAME} will be
/htdocs/www/path/to/pippo.php

Back to what you asked in ``What I'm trying to do'',
I'd use

/.htaccess <<-- .htaccess located in the document root dir
Code: Select all
RewriteEngine On

RewriteCond %{REQUEST_URI} !^/([^/]*)$ [NC]
RewriteCond %{REQUEST_URI} !^/assets/([^/]*)$ [NC]
RewriteCond %{REQUEST_URI} !^/assets/images/([^/]*)$ [NC]

RewriteRule ^(.+)$ http://www.example.com/$1 [R,L]


so if the REQUEST_URI is NOT for the ``root dir'' and NOT for the ``assets dir'' and NOT for the ``assets/images dir'' a redirection will be made to example.com



THanks,
:) Andrea
pippo
 
Posts: 6
Joined: Sat Sep 06, 2003 11:27 pm

Postby boggits » Fri Sep 12, 2003 4:41 am

Thanks thats working very nicely...
boggits
 
Posts: 2
Joined: Thu Sep 11, 2003 5:41 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 39 guests

cron