Forum Moderators: phranque

Message Too Old, No Replies

Missing file_name cond

         

Teschio

4:12 pm on Feb 26, 2005 (gmt 0)

10+ Year Member



Hi to all!
I'd like to do a redirect for missing subdomains...
I have in my httpd.conf this code:

RewriteCond %{REQUEST_FILENAME}!-d
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^(.*) [domain.com...]

and in error.php this code:

$dir = substr($dir, 0, -1);
$dir=explode('/',$dir);
$dir = end($dir);
echo "User <b>".$dir."</b> does not exist!";

With this codes when i digit in the address bar for example:
[non_existent_domain.mydomain2.com...]
It redirects to:
[domain.com...]

and it works! But i'd like to NOT view in the address bar the completely path...
I'd like to view only:
[domain.com...]

How can i do?
Thanks you all
Bye

jdMorgan

6:52 pm on Feb 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Change the rule from an external redirect to an internal rewrite:

RewriteRule ^(.*) /error.php?dir=$1 [L]

Jim

Teschio

3:00 am on Feb 27, 2005 (gmt 0)

10+ Year Member



It doesn't work...
However i think this isn't the solution i need... i'll try to explain better:

The REQUEST_FILENAME is a folder (for e.g john) in the path "/home/web/www.domain.com/website/john/",now
in the "RewriteRule ^(.*) [domain.com...] the "$1" simbol has as value "/home/web/www.domain.com/website/john/" so i will get [domain.com...]

My problem is that i'd like to get simply [domain.com...]

How can i do that?
Thank you

jdMorgan

4:15 am on Feb 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might want to look at the RewriteBase directive for this application:

RewriteBase /home/web/www.domain.com/website/

Actually, it is rather odd that this entire path is appearing as REQUEST_URI. You might want to make sure that your DocumentRoot is set to /home/web/www.domain.com/website/ before modifying the rewrite code. DocumentRoot should point to the "highest-level" folder that is to be accessible via HTTP from the Web. The "Document" in "DocumentRoot" refers to Web-accessible documents.

It really looks to me like a basic configuration problem.

Anyway, the problem can still be fixed in the rewrite code, but I suspect that if you do fix it there rather than in the server configuration, you will keep running into related problems in the future.

Jim

Teschio

2:37 pm on Feb 27, 2005 (gmt 0)

10+ Year Member



Thanks I understood!
I'm trying now with custom apache error pages...
I put in VirtualHost this code:
ErrorDocument 404 [site.com...]
and in error.php this code:
<?php
echo $REQUEST_URI;
?>
I digit in the browser www.site.com/blah (blah does not exist) a i'm redirected to www.site.com/error.php but in the page i can't see "/blah" as "$REQUEST_URI"... i see "/error.php"
What's wrong?