Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design
Showing posts with label htaccess Password. Show all posts
Showing posts with label htaccess Password. Show all posts

PHP Sessions Not working for all pages


If you are getting problem like your php session not working in all pages of your site, than don't worry here you can easily solve your problem if your problem match to my problem i have previously in my site and i solve.

So suppose in your login page you started your session as...

session_start();
$_SESSION['islogin'] = 'true';

but your 'islogin' session is not working for all the pages except few pages. Than may be there is problem in your url. Please check there is a 'www' in your url. If not than add 'www' in your url and try again. If you want to add 'www' in your url using htaccess file than try following.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]

Add these three lines of code in your .htaccess file.

May be this changes solve your problem.

htaccess Password Protect Folder


If you want to protect you directory using htaccess than follow this post.

Protecting files on your website from unauthorized users can be very important. Even more important is the method by which you accomplish this task. You can use PHP to listen for login authorization information on each page, but that doesn't protect your images, documents, and other media. That's why .htaccess method of protecting files and directories the most reliable.

Step1: Creat one .htaccess file as following
AuthName "Authorisation Required"
AuthUserFile "/home/test/public_html/getfile/.htpasswd"
AuthType Basic
require valid-user
ErrorDocument 401 "Authorisation Required"

Step2: Creat one .htpasswd file as following
username:encryptedpassword

The .htpasswd file contains the usernames and passwords of allowed users. One per line. The passwords are MD5'd for security purposes.
e.g. dave:XO5UAT7ceqPvc

That's it.

 

Copyright @ 2017 HKBlog.