How to redirect to specific page if not logged in with .htaccess

前端 未结 5 838
没有蜡笔的小新
没有蜡笔的小新 2021-01-06 00:30

I am running apache2 and php5 in my windows PC.

I have protected my directory using .htaccess and.htpasswd. If login information is not set

5条回答
  •  抹茶落季
    2021-01-06 01:04

    Revised answer...I believe you can do this with mod_rewrite. Here is an example I found:

    # turn on rewrite engine
    RewriteEngine on
    # if authorization header is empty (non-authenticated client)
    RewriteCond %{HTTP:Authorization} ^$
    # redirect to new url
    RewriteRule /current/path /new/path
    

    Caveat emptor...I'm not able to test this at the moment. Give it a try though, put this in your .htaccess and change the paths to suit your environment.

提交回复
热议问题