Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2003
    Posts
    98

    Advanced rewrite rules

    After inserting this into my .htaccess for http://www.domain.com/secure/.htaccess

    RewriteEngine On
    RewriteCond %{SERVER_PORT} !^443$ [OR]
    RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
    RewriteRule ^(.*)$ https://www.domain.com/secure/$1 [R,L]

    I goto http://www.domain.com/secure/ and it takes me to https://www.domain.com/secure/

    However, when I go to http://www.domain.com/secure

    It redirects me to https://www.domain.com/secure//home/username/public_html/secure

    Also, when I goto http://www.domain.com/secure/anotherpage

    It takes me to https://www.domain.com/secure/anotherpage
    which is correct.

    I basically want to make all URLs on the /secure folder to use https instead of http.

    --
    Also, I would like to make a condition, where when the address is http://www.domain.com/secure/another-page-thats-not-secure.php to not rewrite to https

    This is just one page that needs to be unsecure.

  2. #2
    Join Date
    Sep 2003
    Posts
    98
    Thanks for all the help, I finally figured out the answer.

  3. #3
    Join Date
    Jul 2002
    Location
    Kuwait
    Posts
    10,573
    care to share the solution?
    Bashar Al-Abdulhadi - KuwaitNET Internet Services Serving customers since 1997
    Kuwait's First Webhosting and Domain Registration provider - an ICANN Accredited Registrar

    Twitter: Bashar Al-Abdulhadi

  4. #4
    Join Date
    Sep 2003
    Posts
    98
    #turn on the engine
    RewriteEngine On

    #first, correct the www if necessary
    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]

    #then, rewrite secure folder 1
    RewriteCond %{REQUEST_URI} !^/helpdesk/admin/parser.php [NC]
    RewriteCond %{REQUEST_URI} ^/helpdesk/ [NC]
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]

    #then, rewrite secure folder 2
    RewriteCond %{REQUEST_URI} ^/modernbill/ [NC]
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]

    #then, rewrite slashes for secure folder 1
    RewriteCond %{REQUEST_URI} ^/helpdesk [NC]
    RewriteCond %{REQUEST_URI} !^/helpdesk/ [NC]
    RewriteRule ^(.*)$ https://www.domain.com/$1/ [R=301,L]

    #then, rewrite slashes for secure folder 2
    RewriteCond %{REQUEST_URI} ^/modernbill [NC]
    RewriteCond %{REQUEST_URI} !^/modernbill/ [NC]
    RewriteRule ^(.*)$ https://www.domain.com/$1/ [R=301,L]

  5. #5
    Join Date
    Jul 2002
    Location
    Kuwait
    Posts
    10,573
    Thanks!
    Bashar Al-Abdulhadi - KuwaitNET Internet Services Serving customers since 1997
    Kuwait's First Webhosting and Domain Registration provider - an ICANN Accredited Registrar

    Twitter: Bashar Al-Abdulhadi

Posting Permissions

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