You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jeff Poling <jp...@moody.edu> on 2011/01/04 17:22:27 UTC

[users@httpd] Rewrite rules

I am very new to apache configuration, having inherited responsibility for it this fall.  I need some assistance with (hopefully) a simple rewrite rule.

We are using apache in a reverse proxy configuration.  For a URL like:

http://www.mydomain.com/site/test

I want to rewrite it as https://www.mydomain.com/site/test

The trick is that "site" could be any number of different strings.  What regular expression do I need to use to make this work?

Any insight is greatly appreciated!

Jeff

---------------------------------------------------------------------
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] Rewrite rules

Posted by Joost de Heer <jo...@sanguis.xs4all.nl>.
>> As a side note, are there resources you would recommend to help me
>> with this type of task?
>
[List of resources]

There's also Rich Bowen's mod_rewrite book
(http://www.amazon.com/exec/obidos/asin/1590595610/drbacchus/).

Joost

---------------------------------------------------------------------
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] Rewrite rules

Posted by Igor Galić <i....@brainsware.org>.
----- "Jeff Poling" <jp...@moody.edu> wrote:

> Jim,
> 
> Thank you.  That worked really well.
> 
> As a side note, are there resources you would recommend to help me
> with this type of task?

For this particular task:
http://wiki.apache.org/httpd/WhenNotToUseRewrite

For rewrite, when useful:
http://httpd.apache.org/docs/trunk/rewrite/

For httpd in general:
http://wiki.apache.org/httpd/DistrosDefaultLayout
http://httpd.apache.org/docs/current/invoking.html
http://httpd.apache.org/docs/current/glossary.html
http://httpd.apache.org/docs/current/configuring.html
http://httpd.apache.org/docs/current/sections.html

These should get you started. Read them.

When you get stuck:
Step one: Look into the Error Log.

Trouble shooting:
http://wiki.apache.org/httpd/Logs
http://publib.boulder.ibm.com/httpserv/ihsdiag/errorlog.html

And then, there's this list here :)


i

-- 
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.galic@brainsware.org
URL: http://brainsware.org/

---------------------------------------------------------------------
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] Rewrite rules

Posted by Jeff Poling <jp...@moody.edu>.
Jim,

Thank you.  That worked really well.

As a side note, are there resources you would recommend to help me with this type of task?

Jeff

Jeffrey Poling
System Administrator | Information Systems
Moody Bible Institute
820 N. LaSalle Blvd., Chicago, IL 60610
312-329-8968
www.moodyministries.net
>From the Word. To Life.


-----Original Message-----
From: Jim Riggs [mailto:apache-lists@riggs.me] 
Sent: Tuesday, January 04, 2011 10:53 AM
To: users@httpd.apache.org; Jeff Poling
Subject: Re: [users@httpd] Rewrite rules

On Jan 4, 2011, at 10:22 AM, Jeff Poling wrote:

> I am very new to apache configuration, having inherited responsibility for it this fall.  I need some assistance with (hopefully) a simple rewrite rule.
> 
> We are using apache in a reverse proxy configuration.  For a URL like:
> 
> http://www.mydomain.com/site/test
> 
> I want to rewrite it as https://www.mydomain.com/site/test
> 
> The trick is that "site" could be any number of different strings.  What regular expression do I need to use to make this work?

If it's a fixed list, something like this should work:

RewriteCond %{HTTPS} !=on
RewriteRule "^(/(site|foo|bar|baz)/test.*)$" "https://%{HTTP_HOST}$1" [NC,R,L]

Or, for /<anything>/test:

RewriteCond %{HTTPS} !=on
RewriteRule "^(/[^/]+/test.*)$" "https://%{HTTP_HOST}$1" [NC,R,L]


---------------------------------------------------------------------
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


---------------------------------------------------------------------
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] Rewrite rules

Posted by Jim Riggs <ap...@riggs.me>.
On Jan 4, 2011, at 10:22 AM, Jeff Poling wrote:

> I am very new to apache configuration, having inherited responsibility for it this fall.  I need some assistance with (hopefully) a simple rewrite rule.
> 
> We are using apache in a reverse proxy configuration.  For a URL like:
> 
> http://www.mydomain.com/site/test
> 
> I want to rewrite it as https://www.mydomain.com/site/test
> 
> The trick is that "site" could be any number of different strings.  What regular expression do I need to use to make this work?

If it's a fixed list, something like this should work:

RewriteCond %{HTTPS} !=on
RewriteRule "^(/(site|foo|bar|baz)/test.*)$" "https://%{HTTP_HOST}$1" [NC,R,L]

Or, for /<anything>/test:

RewriteCond %{HTTPS} !=on
RewriteRule "^(/[^/]+/test.*)$" "https://%{HTTP_HOST}$1" [NC,R,L]


---------------------------------------------------------------------
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