• 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

Jake Bunce

XenForo moderator
Staff member
#2
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]
 

Mr Lucky

Well-known member
#3
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.
 

Jake Bunce

XenForo moderator
Staff member
#4
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.
 

Jake Bunce

XenForo moderator
Staff member
#5
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]
 

Mr Lucky

Well-known member
#6
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.
 
#9
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]

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.
 

Jake Bunce

XenForo moderator
Staff member
#10
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.
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
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.
 

Jake Bunce

XenForo moderator
Staff member
#12
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.
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