简体   繁体   中英

htaccess - Deny php file access but allow a specific folder

I have a website paytrics.com

This site is working on Codeigniter. I have written a piece of code in htaccess to block direct access of php files. The code is

Please see this image for htacess code

This is working fine. However, here is my problem. I have installed wordpress inside a folder paytrics.com/blog The pages and posts of blog are opening properly.

But since I have blocked access wp-admin of blog So, when I open http://www.paytrics.com/blog/wp-admin it gives me an error that permission is denied.

How to solve this problem? I want direct access of php files denied in my codeigniter project, but I also need to access Wordpress admin section.

In WordPress, if you are trying to access /wp-admin page. It actually redirects to /wp-login.php page. Because WordPress authentication and redirects are managed inside /wp-login.php page.

Since you are blocking access to .php files, try to create an alias for the WordPress directory.

Update your host entry to following,

Alias /blog/ /var/www/wordpress_path
<Directory /var/www/wordpress_path/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    allow from all
</Directory>

Then the .htaccess inside your WordPress install should work, then you can login to the backend.

I hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM