Discussion:
rewriterule for http and https
(too old to reply)
m***@cdsfulfillment.com
2007-10-26 16:21:30 UTC
Permalink
I have a website say www.example.com. This is setup for port 80 and 443. The redirect/rewrite rule I use currently is for the port 80 virtual host for example.com in my httpd.conf file. When the user types www.example.com I want it to redirect to this URL below.

https://www.example.com/webapp/wcs/stores/servlet/VerifyCustomer?storeId=100&type=Emp

So in my Vitural Host for the www.example.com:80 I have my rewrite rule set as this below.

RewriteEngine on
RewriteCond %{QUERY_STRING} promo=1225
RewriteRule /.* https://www.example.com/webapp/wcs/stores/servlet/VerifyCustomer?storeId=100&type=Emp [L]

That part works great if I type http://www.example.com.

In my Virtual Host for www.example.com:443, I don't have anything for RewriteRule, which my problem is if a user goes to https://www.example.com, I will just get a blank page and shows Index of / on it. How can I get the RewriteRule to work for both port 80 and 443 correctly? I tried the same RewriteRule that I have in my port 80 Virtual Host in my 443 Virtual Host stanza in my httpd.conf file, but then it will just keep looping the URL for some reason.

So how can I get the RewriteRule to work for both port 80 and 443?
Eric Covener
2007-10-26 16:33:01 UTC
Permalink
Post by m***@cdsfulfillment.com
I have a website say www.example.com. This is setup for port 80 and 443. The redirect/rewrite rule I use currently is for the port 80 virtual host for example.com in my httpd.conf file. When the user types www.example.com I want it to redirect to this URL below.
https://www.example.com/webapp/wcs/stores/servlet/VerifyCustomer?storeId=100&type=Emp
So in my Vitural Host for the www.example.com:80 I have my rewrite rule set as this below.
RewriteEngine on
RewriteCond %{QUERY_STRING} promo=1225
RewriteRule /.* https://www.example.com/webapp/wcs/stores/servlet/VerifyCustomer?storeId=100&type=Emp [L]
That part works great if I type http://www.example.com.
In my Virtual Host for www.example.com:443, I don't have anything for RewriteRule, which my problem is if a user goes to https://www.example.com, I will just get a blank page and shows Index of / on it. How can I get the RewriteRule to work for both port 80 and 443 correctly?
I tried the same RewriteRule that I have in my port 80 Virtual Host in
my 443 Virtual Host stanza in my httpd.conf file, but then it will just
keep looping the URL for some reason.
Post by m***@cdsfulfillment.com
So how can I get the RewriteRule to work for both port 80 and 443?
It's gotta be conflicting with some existing Rewrite/Redirect in your
port 443 vhost. Try turning on the RewriteLog and RewriteLogLevel 9 to
debug.
m***@cdsfulfillment.com
2007-10-26 18:18:46 UTC
Permalink
Here is my rewrite.log with loglevel 9. When I try to hit https://www.example.com it will just sit there and do nothing in the browser, but the rewrite log file keeps looping it looks like.
m***@cdsfulfillment.com
2007-10-26 18:21:14 UTC
Permalink
Correction in my httpd.conf file in the 443 stanza for my rewrite.log file. I have this

RewriteRule /server-status - [L]
RewriteRule /.* https://www.example.com/webapp/wcs/stores/servlet/TopCategoriesDisplay?langId=-1&storeId=10001&catalogId=10001&activeLink=Home [R=301]
RewriteLogLevel 9
RewriteLog "/weblogs/rewrite.log"
RewriteLogLevel 9
Eric Covener
2007-10-26 19:01:39 UTC
Permalink
Post by m***@cdsfulfillment.com
RewriteRule /.* https://www.example.com/webapp/wcs/stores/servlet/TopCategoriesDisplay?langId=-1&storeId=10001&catalogId=10001&activeLink=Home [R=301]
Your pattern of "/.*" matches "/" and the URL you're redirecting to. Try
the following which only matches a literal request for "/":
RewriteRule ^/$ https://www....
m***@cdsfulfillment.com
2007-10-26 20:05:07 UTC
Permalink
I tried it with the ^/? in both the 80 and 443 stanzas and the https://www.example.com works just fine, but if I try to go to http://www.example.com it won't bring up a page.
Eric Covener
2007-10-26 20:38:12 UTC
Permalink
Post by m***@cdsfulfillment.com
I tried it with the ^/? in both the 80 and 443 stanzas and the https://www.example.com works just fine, but if I try to go to http://www.example.com it won't bring up a page.
That should end in a dollar sign, not a question mark
m***@cdsfulfillment.com
2007-10-26 20:54:05 UTC
Permalink
Typo on the reply on here. I did have a $ instead of a ? in my RewriteRule in my httpd.conf file.
Continue reading on narkive:
Loading...