mod_rewrite

Place to discuss Fedora and/or Red Hat

mod_rewrite

Postby byrdman » Thu Oct 30, 2008 12:52 pm

I thought I would check here because I have always had outstanding assistance here...and I can't comprehend the apache docs for what I am looking for.
I have a webserver running apache at the company I work for. They previously had a client-accessible site on port 80. I now have it secured with SSL but was looking for an easy way to redirect traffic from 80 to 443. I came across the mod_rewrite.
My current config looks like this on my local laptop:

<IfModule rewrite_module>
RewriteEngine On
RewriteCond %{SERVER_PORT} !=80
RewriteRule ^.* - [F]
RewriteRule ^(.*)$ https://our.domain.com%1 [L,R]
</IfModule>
Which works great for one problem...The live site is accessed by clients by going to http://our.domain.com/website. Our team goes to http://192.168.5.2/website for administering the site. If I use the rule above, it rewrites it correctly for the clients but not for our team. I need the rule to rewrite for both outside access and inside access. It basically should just rewrite the "https" but I am too ignorant to figure it out. That is why I come to you all!!

When I get this working, port 80 will eventually be shut off, but in the meantime I want everyone to be redirected.
Modifying the root document won't work because of the network setup, which I have no control of...using mod_rewrite seems to be the only way to redirect port 80 to 443...unless anyone has an easier way...
Thanking you all in advance.
byrdman
administrator
administrator
 
Posts: 225
Joined: Thu May 08, 2003 1:59 pm
Location: In the cloud

Postby Void Main » Thu Oct 30, 2008 11:45 pm

I actually do this on all my servers at work. If you don't have it by then I'll post how I do it tomorrow.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby Void Main » Fri Oct 31, 2008 7:40 am

Here is what I put in my httpd.conf:

Code: Select all
RewriteEngine   on
RewriteCond     %{HTTP_HOST} !^localhost$ [NC]
RewriteCond     %{SERVER_PORT} ^80$
RewriteRule     ^/(.*)$ https://%{SERVER_NAME}/$1 [L,R,NC]


Works like a champ.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA


Return to Fedora/Red Hat

Who is online

Users browsing this forum: No registered users and 1 guest

cron