hamed
hamed

Reputation: 8043

yii2 htaccess allow direct access for a file

I'm working on a yii2 advance application project. I have an .htaccess file with this content in my project root:

Options -Indexes

<IfModule mod_rewrite.c> 
  RewriteEngine on

  RewriteCond %{REQUEST_URI} !^public
  RewriteRule ^(.*)$ backend/web/$1 [L] 
  RewriteRule ^(.*)$ frontend/web/$1 [L] 
</IfModule>

# Deny accessing below extensions
<Files ~ "(.json|.lock|.git)">
   Order allow,deny
   Deny from all
</Files>

# Deny accessing dot files
RewriteRule (^\.|/\.) - [F]

This will hide frontend/web and backend/web from url(official yii wiki).

But, now I need to access just test.php file in my project root directly(without applying MVC structure rules). In fact, I want to access mydomain.com/test.php directly. How can I do this?

Note that I don't want to open direct access for any other files.

Upvotes: 2

Views: 869

Answers (1)

Muhammad Omer Aslam
Muhammad Omer Aslam

Reputation: 23778

if you want a direct access to a specific file you can place it inside the frontend/web directory and that's it, the rules you have defined will work for the hiding of frontend/web, you can access it with mydomain.com/test.php.

Upvotes: 3

Related Questions