?
Solved

pointing domains to my Apache!

Posted on 2009-04-14
14
Medium Priority
?
283 Views
Last Modified: 2013-12-02
when someone points a domain to my apache server, and it is not my domain "it is not in the apache config file", apache should forward the request to my error sites
i put in the .htaccess:

ErrorDocument 400 /var/www/html/errorpage.php
ErrorDocument 401 /var/www/html/errorpage.php
ErrorDocument 403 /var/www/html/errorpage.php
ErrorDocument 404 /var/www/html/errorpage.php
ErrorDocument 500 /var/www/html/errorpage.php

but it is not working, what did i wrong please? or how to do it?

thanks alot
0
Comment
Question by:XXXcool
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 2
14 Comments
 
LVL 29

Expert Comment

by:fosiul01
ID: 24138480
did you place the .httaccess file in top directory ??
0
 
LVL 1

Author Comment

by:XXXcool
ID: 24139467
i have tried both, and now both together :) in the top and at the end, it doesnt work :(
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24139497
what do you meant by top and end ???

there should be only one .httaccess file

suppose your directory is like this

/var/www/mywebsite/

under this mywebsite there are other subdiretories and index.php file

you have to create this under mywebsite directory

so it would be

/var/www/mywebsite/.httaccess

does it like this ??

Directory structure is just a demo
0
Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

 
LVL 1

Author Comment

by:XXXcool
ID: 24139714
i meant:

i tried to put
ErrorDocument 400 /var/www/html/errorpage.php
.....

at the top on the .httaccess and at bottom of it

because i have in the same file ".htaccess" mod_rewrite rules!

it is simply not working regadless where in the .htaccess i put the error handling!
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24139833
ok may be i am not understanding properly

let me asked one thing

are you using .httaccess   file or are you trying to put those line directly in httpd.conf or apache2.conf file ??

0
 
LVL 1

Author Comment

by:XXXcool
ID: 24145880
ErrorDocument 400 /var/www/html/errorpage.php
ErrorDocument 404 /var/www/html/errorpage.php
....

are in the .htaccess
0
 
LVL 1

Author Comment

by:XXXcool
ID: 24149464
? any help plz
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24149609
i am nothing seeting any problem from myside

you said, you have placed the .httacess file in top direcotry , and .httaccess has all the files, still its not working ..

its wired. let me check something on my pc, i will come back
0
 
LVL 27

Expert Comment

by:caterham_www
ID: 24149966
> when someone points a domain to my apache server, and it is not my domain "it is not in the apache config file", apache should forward the request to my error sites

Hm. "points a domain". That reads to me "someone owns example.com and changes the DNS so that example.com points to 10.10.1.15 which is the IP of your server". Is that what you mean by points?

Assuming yes, how did you setup your server? Do you use <virtualhost> sections?

> ErrorDocument 400 /var/www/html/errorpage.php

It looks like you're using a physical path. Apache uses an internal redirect function to fetch the error document, if such a status code (e.g. 400) occurred. The internal redirect needs an URL-path. Assuming your DocumentRoot is /var/www/html, the URL-path would be /errorpage.php,

ErrorDocument 400 /errorpage.php

Anyway, unless no 400 was triggered, your ErrorDocument won't be served.

How can you trigger such a status code? That depends upon your setup (virtual hosts).

One way to catch domains which are pointing via DNS to your server would be a catch-all virtual host like
Namevirtualhost *:80
 
# catch-all
<virtualhost *:80>
Servername invalid
DocumentRoot /var/www/html
RedirectMatch 400 (?!/errorpage\.php)
</virtualhost>
 
# domain1.com
<virtualhost *:80>
Servername domain1.com
ServerAlias www.domain1.com
DocumentRoot /var/www/html
</virtualhost>
 
#domain2.com
<virtualhost *:80>
Servername domain2.com
ServerAlias www.domain2.com
DocumentRoot /var/www/domain2
</virtualhost>
 
#domain3.com
<virtualhost *:80>
Servername domain3.com
ServerAlias www.domain3.com
DocumentRoot /var/www/domain3
</virtualhost>
 
# etc.

Open in new window

0
 
LVL 1

Author Comment

by:XXXcool
ID: 24151750
thanks fosiul01.

and thanks caterham_www,

Hm. "points a domain". That reads to me "someone owns example.com and changes the DNS so that example.com points to 10.10.1.15 which is the IP of your server". Is that what you mean by points?

> yes that is what i meant, and yes i do use <virtualhost> sections, since the DocumentRoot is /var/www/html for me is it the same to write: /var/www/html/errorpage.php or /errorpage.php but it wasnt working so i was trying in diffrenet ways but:

# catch-all
<virtualhost *:80>
Servername invalid
DocumentRoot /var/www/html
RedirectMatch 400 (?!/errorpage\.php)
</virtualhost>

seems to me to be the Solution, i will try it first thing tomorrow and give a feed back :)
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24151770
@XXXcool , sorry i was stuck so i had to refer this question to caterham_www who is realy good in apache server and its good that he is answering here.

I am sorry that i could not able to help you too much
0
 
LVL 1

Author Comment

by:XXXcool
ID: 24159678
the catch all virtualhost seems to be working, now i am getting:

********************

Bad Request

Your browser sent a request that this server could not understand.

********************

but it is not forwarding it to the errorpage.php

?
0
 
LVL 27

Accepted Solution

by:
caterham_www earned 2000 total points
ID: 24159962
Try a different regEx syntax and it looks like I forgot to place your ErrorDocument directive as well.
# requires apache 2.2
RedirectMatch 400  ^/.*+(?<!/errorpage\.php)$
ErrorDocument 400 /errorpage.php

Open in new window

0
 
LVL 1

Author Closing Comment

by:XXXcool
ID: 31569835
it is working fine, thanks :)
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question