You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Paul Laudanski <la...@yahoo.com> on 2002/11/19 20:41:32 UTC

[users@httpd] URL Rewrites - A certain twist, need help.

Hello,

This is the first time I am posting here, and while I
have read http://httpd.apache.org/userslist.html and
the faqts, I was unable to find the information I am
looking for.  That also includes the apache doc page
on mod_rewrite on its URL rewrite examples page.

Here is my problem:

In my .htaccess file I currently cause any of the
following URL examples to be rewritten to
"www.computercops.biz":

 - computercops.biz
 - computercops.info
 - www.computercops.info

Now I am trying to add something like
"scan.computercops.biz" as a subdomain, but when I do,
it gets rewritten to "www.computercops.biz".  I would
like it to stay "scan.computercops.biz".

Currently, if I remove the rewrite conditions as found
in my .htaccess file, then "scan.computercops.biz"
will point to "computercops.biz/scan" due to code in
my index.cgi file.  But because I have the rewrite
code in .htaccess, this does not occur.  Instead it
gets rewritten to "www.computercops.biz".

Unable to find anything in google search, I have hopes
that someone here may be able to guide me.

Thanks,

Paul Laudanski

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] URL Rewrites - A certain twist, need help.

Posted by Paul Laudanski <la...@yahoo.com>.
Understood, thank you.  Now my final question, those
lines I mentioned which I removed for this post
contained ServerAdmin, User, Group, ScriptAlias,
ErrorDocument, and TransferLog.  Should I just include
them once in this section? :

<virtualhost 66.221.179.99>
ScriptAlias ...
User ...
Group ...
ServerAdmin ...
ServerName www.computercops.biz
DocumentRoot /www/computercops
ErrorDocument ...
TransferLog ...
</virtualhost>

Thanks

--- Shaun Fryer <sh...@lweb.net> wrote:
> > Very nice indeed compared to the code in
> mod_rewrite.  So, to get
> > specific for "computercops.biz" itself, I'd like
> to redirect that
> > to "www.computercops.biz".  Does that need to be
> stated too? ...
> 
> 	It is. See the "ServerName" in the last VirtualHost
> below.
> Sorry if I'm confusing you. I could have been more
> specific in my
> first post about this.

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] URL Rewrites - A certain twist, need help.

Posted by Paul Laudanski <la...@yahoo.com>.
Just wanted to thank Shaun for his quick response and
active help.  I tried his recommendations to my
current httpd.conf file without much luck.  So I'll
try his other suggestion, to go bare-bones and build
up.  Perhaps there is something in the conf file which
is preventing his suggestions to work.

In the meantime, I am open to any other suggestions. 
Learning new things is also a plus!

Thanks

Paul

--- Shaun Fryer <sh...@lweb.net> wrote:
> 	It is. See the "ServerName" in the last VirtualHost
> below.
> Sorry if I'm confusing you. I could have been more
> specific in my
> first post about this.
> 
> > <virtualhost 66.221.179.99>
> > ServerName computercops.biz
> > ServerAlias computercops.biz computercops.info
> > www.computercops.info
> > Redirect / http://www.computercops.biz
> > </virtualhost>


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] URL Rewrites - A certain twist, need help.

Posted by Shaun Fryer <sh...@lweb.net>.
> Very nice indeed compared to the code in mod_rewrite.  So, to get
> specific for "computercops.biz" itself, I'd like to redirect that
> to "www.computercops.biz".  Does that need to be stated too? ...

	It is. See the "ServerName" in the last VirtualHost below.
Sorry if I'm confusing you. I could have been more specific in my
first post about this.

> <virtualhost 66.221.179.99>
> ServerName computercops.biz
> ServerAlias computercops.biz computercops.info
> www.computercops.info
> Redirect / http://www.computercops.biz
> </virtualhost>
>
> --- Shaun Fryer <sh...@lweb.net> wrote:
> > It's better to just use 3 VirtualHost containers. One for each
> > of the two DocumentRoots, and one for the Redirects. As follows...
> >
> > <virtualhost 66.221.179.99>
> > ServerName www.computercops.biz
> > DocumentRoot /www/computercops
> > </virtualhost>
> >
> > <virtualhost 66.221.179.99>
> > ServerName scan.computercops.biz
> > DocumentRoot /www/computercops/scan
> > </virtualhost>
> >
> > <virtualhost 66.221.179.99>
> > ServerName computercops.biz
> > ServerAlias computercops.info www.computercops.info
> > Redirect / http://www.computercops.biz
> > </virtualhost>


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] URL Rewrites - A certain twist, need help.

Posted by Paul Laudanski <la...@yahoo.com>.
Very nice indeed compared to the code in mod_rewrite. 
So, to get specific for "computercops.biz" itself, I'd
like to redirect that to "www.computercops.biz".  Does
that need to be stated too? ...

<virtualhost 66.221.179.99>
ServerName computercops.biz
ServerAlias computercops.biz computercops.info
www.computercops.info
Redirect / http://www.computercops.biz
</virtualhost>


--- Shaun Fryer <sh...@lweb.net> wrote:
> 	It's better to just use 3 VirtualHost containers.
> One for each
> of the two DocumentRoots, and one for the Redirects.
> As follows...
> 
> <virtualhost 66.221.179.99>
> ServerName www.computercops.biz
> DocumentRoot /www/computercops
> </virtualhost>
> 
> <virtualhost 66.221.179.99>
> ServerName scan.computercops.biz
> DocumentRoot /www/computercops/scan
> </virtualhost>
> 
> <virtualhost 66.221.179.99>
> ServerName computercops.biz
> ServerAlias computercops.info www.computercops.info
> Redirect / http://www.computercops.biz
> </virtualhost>
> 
> 	Of course using mod_rewrite is somewhat more
> educational, but
> I would think more convoluted than necessary.


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] URL Rewrites - A certain twist, need help.

Posted by Shaun Fryer <sh...@lweb.net>.
> Since scan.computercops.biz is found in
> /www/computercops/scan and www.computercops.biz is
> found in /www/computercops, is this more appropriate?
>
> <virtualhost 66.221.179.99>
> ServerName www.computercops.biz
> ServerAlias scan.computercops.biz
> DocumentRoot /www/computercops/scan
> </virtualhost>
>
> <virtualhost 66.221.179.99>
> ServerName computercops.biz
> ServerAlias computercops.info www.computercops.info
> Redirect / http://www.computercops.biz
> DocumentRoot /www/computercops
> </virtualhost>

	It's better to just use 3 VirtualHost containers. One for each
of the two DocumentRoots, and one for the Redirects. As follows...

<virtualhost 66.221.179.99>
ServerName www.computercops.biz
DocumentRoot /www/computercops
</virtualhost>

<virtualhost 66.221.179.99>
ServerName scan.computercops.biz
DocumentRoot /www/computercops/scan
</virtualhost>

<virtualhost 66.221.179.99>
ServerName computercops.biz
ServerAlias computercops.info www.computercops.info
Redirect / http://www.computercops.biz
</virtualhost>

	Of course using mod_rewrite is somewhat more educational, but
I would think more convoluted than necessary.

===================
 Shaun Fryer
===================
 London Webmasters
 http://LWEB.NET
 PH:  519-858-9660
 FX:  519-858-9024
===================


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] URL Rewrites - A certain twist, need help.

Posted by Paul Laudanski <la...@yahoo.com>.
Since scan.computercops.biz is found in
/www/computercops/scan and www.computercops.biz is
found in /www/computercops, is this more appropriate?

<virtualhost 66.221.179.99>
ServerName www.computercops.biz
ServerAlias scan.computercops.biz
DocumentRoot /www/computercops/scan
</virtualhost>

<virtualhost 66.221.179.99>
ServerName computercops.biz
ServerAlias computercops.info www.computercops.info
Redirect / http://www.computercops.biz
DocumentRoot /www/computercops
</virtualhost>


--- Shaun Fryer <sh...@lweb.net> wrote:
> How about the following...
> 
> <virtualhost 66.221.179.99>
> ServerName www.computercops.biz
> ServerAlias scan.computercops.biz
> DocumentRoot /www/computercops
> </virtualhost>
> 
> <virtualhost 66.221.179.99>
> ServerName computercops.biz
> ServerAlias computercops.info www.computercops.info
> Redirect / http://www.computercops.biz
> </virtualhost>


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] URL Rewrites - A certain twist, need help.

Posted by Shaun Fryer <sh...@lweb.net>.
How about the following...

<virtualhost 66.221.179.99>
ServerName www.computercops.biz
ServerAlias scan.computercops.biz
DocumentRoot /www/computercops
</virtualhost>

<virtualhost 66.221.179.99>
ServerName computercops.biz
ServerAlias computercops.info www.computercops.info
Redirect / http://www.computercops.biz
</virtualhost>

===================
 Shaun Fryer
===================
 London Webmasters
 http://LWEB.NET
 PH:  519-858-9660
 FX:  519-858-9024
===================


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] URL Rewrites - A certain twist, need help.

Posted by Paul Laudanski <la...@yahoo.com>.
Fix to previous post:

if ($ENV{'HTTP_HOST'} =~
/(www\.|^)scan.computercops.biz/)
{$url = "http://$ENV{'HTTP_HOST'}/scan"}


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] URL Rewrites - A certain twist, need help.

Posted by Paul Laudanski <la...@yahoo.com>.
That is a good question.  I've quickly checked some
links:

http://httpd.apache.org/docs/mod/core.html#serveralias
http://www.tss.nwu.edu/reference/northwestern-edu-apache.html

I presume I would need to go from the following (some
lines cut out):

<virtualhost www.computercops.biz>
ServerName www.computercops.biz
DocumentRoot /www/computercops
</virtualhost>

To something like this...?

<virtualhost 66.221.179.99>
ServerName www.computercops.biz
ServerAlias computercops.biz
ServerAlias www.computercops.net
ServerAlias computercops.net
DocumentRoot /www/computercops
</virtualhost>

But I'm not sure how that would help me in redirecting
to "www.computercops.biz" while being able to maintain
"scan.computercops.biz"?

Instead of my current .htaccess rewrite:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.computercops\.biz$
[NC]
RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteRule (.*)  http://www.computercops.biz/$1 [R]

What if I did something like this?

RewriteEngine on
RewriteCond %{HTTP_HOST}    !^$
RewriteCond %{HTTP_HOST}    !=scan.computercops.biz   
             [NC]
RewriteRule ^/$            
http://scan.computercops.biz/           [R,L,NS]
RewriteCond %{HTTP_HOST}    !=www.computercops.biz    
             [NC]
RewriteRule ^/$            
http://www.computercops.biz/$1          [R,L,NS]

Do I have my logic correct here?

In this scenario, if "scan.computercops.biz" is
processed, would it be re-routed to
"www.computercops.biz/scan" due to the index.cgi code:

#!/usr/bin/perl

$url="";

if ($ENV{'HTTP_HOST'} =~
/(www\.|^)packetstorm.computercops.biz/)
{$url = "http://$ENV{'HTTP_HOST'}/packetstorm"}

if($url eq "")
{$url="http://www.computercops.biz/index.php"}

And then if it sees anything other than
"scan.computercops.biz" it would get rewritten to
"www.computercops.biz"?

Hmm.. I get the feeling you are right, I am over
complicating this and cannot see the trees in the
forest.

Thanks

--- Shaun Fryer <sh...@lweb.net> wrote:
> It seem to me you're doing this the hard way. Unless
> you have a
> specific reason not to, why not use ServerAlias
> rather than
> mod-rewrite?


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] URL Rewrites - A certain twist, need help.

Posted by Shaun Fryer <sh...@lweb.net>.
It seem to me you're doing this the hard way. Unless you have a
specific reason not to, why not use ServerAlias rather than
mod-rewrite?

===================
 Shaun Fryer
===================
 London Webmasters
 http://LWEB.NET
 PH:  519-858-9660
 FX:  519-858-9024
===================

On Tue, 19 Nov 2002, Paul Laudanski wrote:

> Date: Tue, 19 Nov 2002 11:41:32 -0800 (PST)
> From: Paul Laudanski <la...@yahoo.com>
> Reply-To: users@httpd.apache.org
> To: users@httpd.apache.org
> Subject: [users@httpd] URL Rewrites - A certain twist, need help.
>
> Hello,
>
> This is the first time I am posting here, and while I
> have read http://httpd.apache.org/userslist.html and
> the faqts, I was unable to find the information I am
> looking for.  That also includes the apache doc page
> on mod_rewrite on its URL rewrite examples page.
>
> Here is my problem:
>
> In my .htaccess file I currently cause any of the
> following URL examples to be rewritten to
> "www.computercops.biz":
>
>  - computercops.biz
>  - computercops.info
>  - www.computercops.info
>
> Now I am trying to add something like
> "scan.computercops.biz" as a subdomain, but when I do,
> it gets rewritten to "www.computercops.biz".  I would
> like it to stay "scan.computercops.biz".
>
> Currently, if I remove the rewrite conditions as found
> in my .htaccess file, then "scan.computercops.biz"
> will point to "computercops.biz/scan" due to code in
> my index.cgi file.  But because I have the rewrite
> code in .htaccess, this does not occur.  Instead it
> gets rewritten to "www.computercops.biz".
>
> Unable to find anything in google search, I have hopes
> that someone here may be able to guide me.
>
> Thanks,
>
> Paul Laudanski


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org