Link to home
Start Free TrialLog in
Avatar of Dodger42
Dodger42

asked on

Apache redirects

Hey there,

Wondering if its possible with apache to configure redirection as follows:

source = localhost -> /
source = anything else -> /clients

??

Sorry for the newb question! :)
Avatar of Dodger42
Dodger42

ASKER

To add to that, the reason being is I have a script on localhost which needs to run on the /, but I prefer clients to see another web page if they happen to browse to the server.
the variable for client requests host is %{REMOTE_ADDR} .
so for you something like:
RewriteCond   %{REMOTE_ADDR}     ! ^127\.0\.0\.1$  #if  request host is diffrent than 127.0.0.1
RewriteRule ^/$                          http://<domainname>/client/   [L,R]   # redirect  / request to <domain>/client
Would that be with mod_rewrite, or standard conf?
mod_rewrite.
and you have to enable  rewrite with:
 RewriteEngine on (just before the other  rewrite directives).
sorry, forgot to ask if you have mod_rewrite installed......
I have enabled the rewrite module. Do I put the RewriteEngine on directive and rules in the .htaccess file?
ASKER CERTIFIED SOLUTION
Avatar of Tol_cv
Tol_cv

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Or I presume it is also fine to put this in the <Directory> section if im not using a virtualhost?

Thanks.
above the  <directory>  section  will be fine...
I tried that but got a 404 error. I tried turning on logging as follows:

RewriteLog "d:/www/rewrite.txt"
RewriteLoglevel 0

But when I do that, apache fails to start.

All lines are before the directory section.
go to the   bin directory of apache and type :  apache -t . or look in error log why it dosn't start. my guess is that it can open the log file
Aparrently (I read) even if apache cant open the log file, it wont tell you with apache -t.

And the file definitely exists.
apache -t tests   apache configuration and reports errors.

also is start fails the errror is somewhere in logs.