1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.5 Redirect https to just one page

Discussion in 'XenForo Questions and Support' started by Mr Lucky, May 10, 2016.

  1. Mr Lucky

    Mr Lucky Well-Known Member

    Does anyone know the best way with .htaccess to redirct just one page to https?

    e.g. I want to redirect http://domain.com/pages/sales to https://domain.com/pages/sales

    A normal Redirect 301 / doesn't seem to work.

    I also need to make sure that after leaving that page, all other pages are still http

    Thanks!
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Add these rules to the top of the .htaccess file in your web root:

    Code:
    	RewriteCond %{SERVER_PORT} 80
    	RewriteRule ^(pages/sales/?)$ https://domain.com/$1 [R,L]
    	RewriteCond %{SERVER_PORT} 443
    	RewriteRule ^(pages/sales/?)$ - [S=1]
    	RewriteRule ^(.*)$ http://domain.com/$1 [R,L]
    
     
  3. Mr Lucky

    Mr Lucky Well-Known Member

    Thanks jake, but sadly is not working, it gives me a 404 for the entire site when I try it with my xenforo site. On another (wordpress) site I get this:

    Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

    This problem can sometimes be caused by disabling or refusing to accept cookies.
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Hmm. Try this:

    Code:
    	RewriteCond %{SERVER_PORT} 80
    	RewriteRule ^(pages/sales/?)$ https://domain.com/$1 [R,L]
    
    	RewriteRule ^(pages/sales/?)$ - [S=1]
    	RewriteCond %{SERVER_PORT} 443
    	RewriteRule ^(.*)$ http://domain.com/$1 [R,L]
    
    The logic is a bit squirrelly, but I think this new order of rules will work correctly, whereas the old order was an error on my part.
     
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    uhhhh, or this is probably better...

    Code:
    	RewriteCond %{SERVER_PORT} 80
    	RewriteRule ^(pages/sales/?)$ https://domain.com/$1 [R,L]
    
    	RewriteCond %{SERVER_PORT} 443
    	RewriteCond %{REQUEST_URI} !pages/sales/?$
    	RewriteRule ^(.*)$ http://domain.com/$1 [R,L]
    
     
  6. Mr Lucky

    Mr Lucky Well-Known Member

    Thanks for your suggestions Jake, and I apologise as I meant to reply sooner.

    So far the tests I have done are still not working. I will try again today, doublechecking in case I got something wrong. It has been suggested by my host @MattW that the issue may be that /pages/ is not a real folder as such.

    I get the same issue when I try on my Wordpress site which again has a URL structure that looks like a real directory on the server but isn't.

    EDIT: I have also tried doing a redirect via cpanel and that doesn't work either.
     
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I can take a look if you PM me your info
     
    Mr Lucky likes this.
  8. Mr Lucky

    Mr Lucky Well-Known Member

    jake, that is brilliant! thank you.

    Let me just first double check i haven't done anything stupid
     
  9. cjesuele

    cjesuele New Member


    Hello, how do I redirect ONLY my "domain.com/forums/" to "domain.com/pages/page-title/" without disrupting my actual forums & threads where users are posting?

    Would want these type of links to remain active and working - domain.com/forums/forum-title/

    Would like to only redirect the main /forums/ page.
     
  10. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Add these rules to the top of the .htaccess file in your web root:

    Code:
    RewriteEngine On
    
    RewriteRule ^forums/$ /pages/page-title/ [R=301,L]
    
     
  11. stacy.c

    stacy.c Member

    Similar question: I would like to force HTTPS only on the /account directory.

    I found some instructions that suggested placing an .htaccess file in the /account directory, but there is not an actual directory on the server by this name.

    Any suggestions on how to accomplish this? What I am trying to do is secure the account upgrades page for Stripe credit card entry.

    Thanks.
     
  12. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I apparently failed to create a working rule for this. But this is probably not advisable anyways. Just make everything https to ensure consistency and to avoid possible problems with mixed content and cookies.

    https://xenforo.com/community/threads/xenforo-always-use-ssl.36180/#post-411628
     
    Amaury likes this.

Share This Page