• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

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! :)
0
Dodger42
Asked:
Dodger42
  • 7
  • 6
1 Solution
 
Dodger42Author Commented:
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.
0
 
Tol_cvCommented:
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
0
 
Dodger42Author Commented:
Would that be with mod_rewrite, or standard conf?
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
Tol_cvCommented:
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......
0
 
Dodger42Author Commented:
I have enabled the rewrite module. Do I put the RewriteEngine on directive and rules in the .htaccess file?
0
 
Tol_cvCommented:
no, you add it in your apache httpd.conf.-  in your virtual host.
<VirtualHost ...>
....
RewriteEngine on
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
.....

</VirtualHost>>
0
 
Dodger42Author Commented:
Or I presume it is also fine to put this in the <Directory> section if im not using a virtualhost?

Thanks.
0
 
Tol_cvCommented:
above the  <directory>  section  will be fine...
0
 
Dodger42Author Commented:
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.
0
 
Tol_cvCommented:
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
0
 
Dodger42Author Commented:
Aparrently (I read) even if apache cant open the log file, it wont tell you with apache -t.

0
 
Dodger42Author Commented:
And the file definitely exists.
0
 
Tol_cvCommented:
apache -t tests   apache configuration and reports errors.

also is start fails the errror is somewhere in logs.
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now