ترقية الحساب

[Solution] Redirect to a custom page when not logged in.

Richard Wing
2025-01-26 01:11:10

I wanted to show a html page that highlights all the benefits and features of my sngine niche site for first timers so they can be sold on why to join.

add the following code to the top of you .htaccess file

RewriteEngine On

 

# Check if c_user cookie exists (user is logged in)
RewriteCond %{HTTP_COOKIE} c_user= [NC]
RewriteRule ^$ - [L]

 

# Redirect to /i/ if c_user cookie does not exist (user is logged out)
RewriteCond %{HTTP_HOST} ^(www\.)?sitename\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/i/ [NC]
RewriteRule ^$ /i/ [L,R=301,NE,QSD]

 

----
edits

1. change the /i/ which is the directory I wanted to send not logged in users if they go to the main url of my site to /yourcustomfoldername/ in your folder you can place an index.html 

2. change sitename\.com to yourdomain\.com be sure to leave the \ before the tld \.com or \.net or .\org etc...

 

Enjoy
Richard Wing

Jane Marcia
2025-01-26 07:16:23

Sweet! Thank you :)

Victor Gonzales
2025-01-27 03:37:33

Sweet!! Thanks a lot.