Results 1 to 10 of 10

Thread: Port 443 and Port 80 Apache

  1. #1
    Join Date
    Jun 2008
    Location
    Dublin, Ireland
    Posts
    298

    Default Port 443 and Port 80 Apache

    Hi,

    My site runs on port 443 but I still want people to be able to access it if they type http:// instead of https://

    To that end I have been trying to redirect all http requests to https using this rewrite rule

    Code:
    RewriteEngine On
    RewriteCond %{SERVER_PORT} ^443$
    RewriteRule ^.*$ https://%{SERVER_NAME}[L,R]
    However, it doesn't actually change the url to https://. It loads the page using the DocumentRoot of the https connection but it doesn't change the URL.


    Any ideas?

    /Jlar

  2. #2
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: Port 443 and Port 80 Apache

    Yes, your rule is missing something

    Code:
    RewriteEngine on
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

  3. #3
    Join Date
    Jun 2008
    Location
    Dublin, Ireland
    Posts
    298

    Default Re: Port 443 and Port 80 Apache

    Thanks ken_yap, perhaps you could enlighten me as to what it's missing... It looks right..!!

    I have been rooting around at this for two months, and I have tried putting rewrite rules in the Apache config, in the root of the web server - everywhere. Nothing works. I have tried countless combinations. I know it's possible. There are loads of sites that use it.

    Any help greatly appreciated..

    /jlar

  4. #4
    eeijlar NNTP User

    Default Re: Port 443 and Port 80 Apache


    Thanks ken_yap, perhaps you could enlighten me as to what it's
    missing... It looks right..!!

    I have been rooting around at this for two months, and I have tried
    putting rewrite rules in the Apache config, in the root of the web
    server - everywhere. Nothing works. I have tried countless combinations.
    I know it's possible. There are loads of sites that use it.

    Any help greatly appreciated..

    /jlar


    --
    eeijlar
    ------------------------------------------------------------------------
    eeijlar's Profile: http://forums.opensuse.org/member.php?userid=1504
    View this thread: http://forums.opensuse.org/showthread.php?t=399579


  5. #5
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: Port 443 and Port 80 Apache

    Just eyeball your code and mine and you will see what the difference is.

  6. #6
    ken yap NNTP User

    Default Re: Port 443 and Port 80 Apache


    Just eyeball your code and mine and you will see what the difference is.


    --
    ken_yap
    ------------------------------------------------------------------------
    ken_yap's Profile: http://forums.opensuse.org/member.php?userid=221
    View this thread: http://forums.opensuse.org/showthread.php?t=399579


  7. #7
    Join Date
    Jun 2008
    Location
    Dublin, Ireland
    Posts
    298

    Default Re: Port 443 and Port 80 Apache

    Yeah I tried adding the %{REQUEST_URI} that is in your code. It didn't make any difference. I already have a rewrite rule in the htdocs directory which redirects all requests to index.php. I don't know if that is messing things up...

  8. #8
    eeijlar NNTP User

    Default Re: Port 443 and Port 80 Apache


    Yeah I tried adding the %{REQUEST_URI} that is in your code. It didn't
    make any difference. I already have a rewrite rule in the htdocs
    directory which redirects all requests to index.php. I don't know if
    that is messing things up...


    --
    eeijlar
    ------------------------------------------------------------------------
    eeijlar's Profile: http://forums.opensuse.org/member.php?userid=1504
    View this thread: http://forums.opensuse.org/showthread.php?t=399579


  9. #9
    Join Date
    Jun 2008
    Location
    Dublin, Ireland
    Posts
    298

    Default Re: Port 443 and Port 80 Apache

    I finally figured this out... it was all down to a simple directive in the default-server.conf

    AllowOverride None

    which means all .htaccess is disabled for that directory. The reason it was working in the Virtual host was because I had AllowOverride All for that directory.

    /jlar

  10. #10
    eeijlar NNTP User

    Default Re: Port 443 and Port 80 Apache


    I finally figured this out... it was all down to a simple directive in
    the default-server.conf

    AllowOverride None

    which means all .htaccess is disabled for that directory. The reason it
    was working in the Virtual host was because I had AllowOverride All for
    that directory.

    /jlar


    --
    eeijlar
    ------------------------------------------------------------------------
    eeijlar's Profile: http://forums.opensuse.org/member.php?userid=1504
    View this thread: http://forums.opensuse.org/showthread.php?t=399579


Posting Permissions

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