John Davidson

php - Can't access file in directory outside of wordpress

0 comments
Message:


Hi I have a a standard wordpress installation on my server, I have added a etc folder in the root i.e. this is how it looks :


etc
wp-admin
wp-content
index.php
.htaccess

The .htaacess look like this


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

When I try to access a php script inside the "etc" folder I get "No such file or directory" error. I assume this is down to the .htaccess file. What do I need to add to the. .htaaccess to allow etc folder scripts to be accessed ?



My Answer:
You can add an exception to the .htaccess file to allow access to the "etc" folder. You can do this by adding the following lines before the # BEGIN WordPress section:


RewriteCond %{REQUEST_URI} !^/etc/


This will exclude the "etc" folder from the WordPress rewrite rules and allow you to access files within that folder directly. Make sure to adjust the path in the RewriteCond rule if the folder is located in a different directory.

Rate this post

4 of 5 based on 3753 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us