SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Feb 2002
    Location
    Indianapolis, IN USA
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy redirect and/or mod_rewrite woes

    I'll start off by saying that I'm a total idiot when it comes to this. So here I am pleading for a little help.

    We are running IBM iSeries for OS/400. The site has been running with the IBM Original HTTP Server. However, recently my manager wanted to switch to Apache. So he went through the migration wizard that comes with the iSeries to migrate from IBM HTTP Server to Apache. The wizard creates the new Apache httpd.conf file based on the config of the other server.

    Anyway, things work great so far. However, I'm having a bit of a problem with redirecting. At least, that is part of my problem, I think.

    Everything on this site should be secured. So I'm trying to redirect any requests that are not https://.

    If a user types in https://www.mydomain.com OR https://www.mydomain.com/ OR https://www.mydomain.com/index.html it redirects correctly to the page I want it to redirect to :
    https://www.mydomain.com/cgi-bin/login.mbr/login

    However, if a user types in http://www.mydomain.com, or anything referring to this site that is NOT https, it just hangs for a while and bombs out, page cannot be displayed. It's like the server will only accept requests from HTTPS, which needs to be changed.

    What I want is that any requests to http://www.mydomain.com or http://mydomain.com/ or http://www.mydomain.com/index.html or http://www.mydomain.com/cgi-bin/login.mbr/login will all redirect to
    https://www.mydomain.com/cgi-bin/login.mbr/login

    I know in the config file it is using the IBM SSL Module by this directive:
    LoadModule ibm_ssl_module /QSYS.LIB/QHTTPSVR.LIB/QZSRVSSL.SRVPGM

    I will attach the config file so far...just in case. Please keep in mind that I've been playing around a lot, and I am new to all of this, so please don't chastise me too much!

    Sorry for being long-winded. If you've made it this far, thanks for reading and trying to help in advance!

    Jill
    Attached Files Attached Files

  2. #2
    SitePoint Zealot
    Join Date
    Oct 2003
    Location
    USA
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's one way to do it in the HTML:
    <meta http-equiv="refresh" content="0;URL=https://www.mydomain.com/cgi-bin/login.mbr/login">
    .
    2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
    2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
    2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

  3. #3
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have to say that looking at your httpd.conf,
    well it's a lot confused!
    For example:

    RewriteEngine on
    RewriteCond %{HTTPS} !=on [NC]
    RewriteRule ^/$ https://172.17.0.78/cgi-bin/login.mbr/login [R,L]
    RewriteCond %{SERVER_PORT} ^80$
    RewriteRule ^/$ https://172.17.0.78/cgi-bin/login.mbr/login [R,L]

    I don't understand what's the logic of what I marked in bold

    also
    RewriteEngine on
    RewriteCond %{SERVER_PORT} ^80$
    RewriteRule ^/index\.html$ https://172.17.0.78/cgi-bin/login.mbr/login [R,L]
    RewriteRule ^/$ https://172.17.0.78/cgi-bin/login.mbr/login [R,L]
    RewriteCond %{SERVER_PORT} ^443$
    RewriteRule ^/index\.html$ https://172.17.0.78/cgi-bin/login.mbr/login [R,L]
    RewriteRule ^/$ https://172.17.0.78/cgi-bin/login.mbr/login [R,L]

    remember that RewriteCond will be used in conjuction with the next line only, the lines marked in bold.
    What I underlined will ignore the RewriteCond.

    By the way I don't see where mod_rewrite is loaded .

    I have the suspect that the script that generated the httpd.conf did a lot of confusion.
    Maybe it was better to start from scratch, but I have to say that I never used https so I cannot help on configuring SSL.

    Finally this is the correct rule to redirect all requests from http to https.

    Code:
    RewriteEngine On
    #
    # Redirects all http to https
    #
    RewriteCond %{SERVER_PORT} ^80$
    RewriteRule ^.*$ https://www.example.com/cgi-bin/login.mbr/login  [R,L]
    #
    # Redirect index.html, indipendent of the port, to https
    #
    RewriteRule ^/index\.html$ https://www.example.com/cgi-bin/login.mbr/login [R,L]

    hope it helped a bit,


    let me know
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  4. #4
    SitePoint Member
    Join Date
    Feb 2002
    Location
    Indianapolis, IN USA
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is so awful.

    I have no idea now where to begin. Perhaps I don't have mod_rewrite loaded, but I don't even know how to load it. I mean I read the FAQs and all kinds of posts and information on mod_rewrite, but this is all so foreign to me. And it isn't like I did the install and config. I don't know how to go about loading mod_rewrite.

    I assume I'd need to add the following to my config:
    LoadModule rewrite_module modules/mod_rewrite.so

    However, I don't know where that file is and/or if it exists.

    The good news is, I was pretty close on my regex for the rewrite. I just had a bunch of other useless crap.

    Oh well, back to the drawing board.

    Thanks for your help!

  5. #5
    SitePoint Member
    Join Date
    May 2003
    Location
    Paris, France
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Redhat_PHP
    Here's one way to do it in the HTML:
    <meta http-equiv="refresh" content="0;URL=https://www.mydomain.com/cgi-bin/login.mbr/login">
    I used this and it sent my Flash based site into a reloading loops when setting this up to redirect to https://www.mydomain.com.

    Any ideas why it does this. It did redirect, but it loops and reloads the page unstoppably.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •