0

I am working on Yii2. My main URL is http://ip/backend/web/. Whenever a user opens this link he will be redirected towards a home page

But if a user changes the URL from http://ip/backend/web/ to http://ip/backend/ the below screen will be shown

I want all users not to access it. Like if anyone hit the http://ip/backend/ it will not allow any user to see that page

I searched for the solution and found out the following link Prevent users from accessing a url directly Yii 2 but still, I am unable to perform the task

How can I do this?

Biffen
  • 6,249
  • 6
  • 28
  • 36
Moeez
  • 494
  • 9
  • 55
  • 147

1 Answers1

2

create a .htaccess file at backend folder in your project.

# prevent directory listings
Options -Indexes
IndexIgnore */*

# follow symbolic links
Options FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)?$ web/$1

or Options -Indexes

But this is not perfect
You have to do this through the root of the project. And configure access to the frontend and backend folders. And prevent indexing all folders and files.

create a .htaccess file at root folder in your project.
For content depending on your project and folders, get help through the links below
Link 1 , Link 2, Link 3 , link 4

create a .htaccess file manually in Windows:
start Notepad and then File->Save As. And Write .htaccess and choose "All Files" as the type. Save at the end.

user206
  • 1,085
  • 1
  • 10
  • 15