Forum Moderators: phranque
I am a newbie... both to the forums here on this site and to Apache http server configuration... although I am very technical, i simply have no experience w/ Apache.
With that, I have been left in the unenviable position of inheriting management of an http server from a co-worker who left the company for greener pastures.
Here's the situation: We had to move the http server in question from one IBM iSeries (AS/400) Apache server to another. Everything is working great, and I even managed to move the SSL certificate (which is no small chore on the iSeries), but there is still one problem... http to https redirection.
It doesn't seem to work anymore now that it's been moved to another box, and the httpd.conf file was moved across without any alternations.
I've done as much as I can researching redirection and the "rewrite engine" with no success.
As an add-on, i'd also like some assistance w/ rewriting the URLs on this site. Figured as long as I'm begging for help here, I might as while pile on w/ another question. ;-)
Anyway, here's my pasted "httpd.conf" file:
--------------------------
# Configuration originally created by Create HTTP Server wizard on Thu Oct 30 09:55:08 PDT 2008
LoadModule ibm_ssl_module /QSYS.LIB/QHTTPSVR.LIB/QZSRVSSL.SRVPGM
Listen 10.6.100.2:80
Listen 10.6.100.2:443
DocumentRoot /jwalk/
Options -ExecCGI -FollowSymLinks -SymLinksIfOwnerMatch -Includes -IncludesNoExec -Indexes -MultiViews
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%{Cookie}n \"%r\" %t" cookie
LogFormat "%{User-agent}i" agent
LogFormat "%{Referer}i -> %U" referer
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogMaint logs/error_log 7 0
NameVirtualHost timekeeper.domain.com:443
ServerName timekeeper.domain.com:80
SetEnvIf "User-Agent" "Mozilla/2" nokeepalive
SetEnvIf "User-Agent" "JDK/1\.0" force-response-1.0
SetEnvIf "User-Agent" "Java/1\.0" force-response-1.0
SetEnvIf "User-Agent" "RealPlayer 4\.0" force-response-1.0
SetEnvIf "User-Agent" "MSIE 4\.0b2;" nokeepalive
SetEnvIf "User-Agent" "MSIE 4\.0b2;" force-response-1.0
DirectoryIndex kisc51enwin.html
SSLAppName QIBM_HTTP_SERVER_KRONOS
SSLEngine On
SetEnv HTTPS_PORT 443
RewriteEngine On
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^/$ [timekeeper.domain.com...] [L]
<Directory />
Order Deny,Allow
Deny From all
</Directory>
<Directory /kronos>
Order Allow,Deny
Allow From all
</Directory>
<Directory /jwalk/>
Order Allow,Deny
Allow From all
</Directory>
Alias /kronos/ /kronos/
# Added for Manager HTML
CGIConvMode %%EBCDIC/EBCDIC%%
ScriptAliasMatch ^/timekeeper/(.*) /QSYS.LIB/TIMEKEEPER.LIB/$1.PGM
AliasMatch ^/kronos/(.*) /kronos/$1
Redirect 307 /manager [timekeeper.domain.com...]
Redirect 307 /employee [timekeeper.domain.com...]
<Directory /kronos/>
Allow From all
</Directory>
<Directory /QSYS.LIB/TIMEKEEPER.LIB/>
Allow From all
</Directory>
<VirtualHost timekeeper.domain.com:443>
ServerName kronos
DocumentRoot /jwalk/
SSLEngine On
SSLAppName QIBM_HTTP_SERVER_KRONOS
SetEnv HTTPS_PORT 443
</VirtualHost>
--------------------------
So, to clarify, i'm looking for all requests to [timekeeper.domain.com...] to redirect to [timekeeper.domain.com...]
In addition, the ugly URLs from the "Redirect 307" lines could be cleaned up with rewrites.
Specifically, when the URL "http://timekeeper.domain.com/manager" is accessed, instead of the super ugly "https://timekeeper.domain.com/timekeeper/clw0004?scrdbcoid=FILE00", it'd be nice if we could rewrite the URL to remain a much cleaner "https://timekeeper.domain.com/manager" version (and likewise w/ the '/employee" URL).
Hopefully a fairly easy task, but w/ my limited experience, is enough to peak my frustrations.
My apologies for the extremely novice nature of my questions here. As I said, i'm truly green here.
Thanks in advance for any assistance.
John
What are you asking about, this rule here?
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^/$ https://timekeeper.example.com [L]
You're saying that this rule previously functioned to redirect http://timekeeper.example.com/<anything> to [timekeeper.domain.com...] and that it stopped working when you changed servers? That would be very odd, because the function you describe would require the rule to be more like:
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^/(.*)$ https://timekeeper.example.com/$1 [L]
Jim
[edited by: jdMorgan at 1:35 am (utc) on Nov. 21, 2008]
As to your questions, it's a really simple site, there are only two pages/functions, one for the manager, and one for the employee time entry (it's a time and attendance site).
Also, i should have mentioned that the RewriteRule in my original pasted code is suspect, as there was some trial-and-error tweaking done by another tech here, and I suspect he never returned the code to it's original state.
I'll try the suggested Rewrite instead. Thanks.
As to your final question, yes, https is the permanently correct URL.
Now, can anyone recommend a novice guide to URL rewriting? I really want to learn this stuff, and more specifically, clean up those ugly 307 redirect URLs.
Thanks again,
John
Then you'll need to adjust the rule slightly.
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^/(.*)$ https://timekeeper.example.com/$1 [[b]R=301,[/b]L]
For example, the reason I asked about the 301 versus 302 redirect had more to do with search engines than with technical strictness. A 301 tells a search engine "discard the old URL and use this one," whereas a 302 says, "keep the old URL, and ascribe the contents of this other URL to that original URL."
Browsers really don't care which one you use; I'm not aware of any mainstream browser that ever updated or offered to update a bookmark because of receiving a 301 redirect, although that was one of the intended functions described in the HTTP specification. The rise of search engines removed most of the incentive for anyone to bother with implementing fancy bookmark-related browser features; Many Web users today don't even know what a bookmark or IE Favorite is...
Take a look through the Apache section of the WebmasterWorld Library before tackling your URL clean-up. There are several good "backgrounder" threads in there. Links to the Forum Charters and Library are near the top left of every page here at WebmasterWorld.
Jim