从重写 htaccess 中排除文件和文件夹



我在服务器上安装了wordpress。 我还在服务器上上传了名为himanshu的自定义目录。当我尝试访问其中的文件或通过 URL 直接访问文件夹时,它显示 404 文件未找到错误。

.htaccess 在这里。

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php5_module>
php_flag asp_tags Off
php_flag display_errors Off
php_value max_execution_time 120
php_value max_input_time 120
php_value max_input_vars 1000
php_value memory_limit 1024M
php_value post_max_size 50M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php54"
php_value upload_max_filesize 50M
php_flag zlib.output_compression On
</IfModule>
<IfModule lsapi_module>
php_flag asp_tags Off
php_flag display_errors Off
php_value max_execution_time 120
php_value max_input_time 120
php_value max_input_vars 1000
php_value memory_limit 1024M
php_value post_max_size 50M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php54"
php_value upload_max_filesize 50M
php_flag zlib.output_compression On
</IfModule>
# END cPanel-generated php ini directives, do not edit
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php54” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php54 .php .php5 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

RewriteRule ^index.php$ - [L]之前添加以下代码

# exclude file
RewriteCond %{REQUEST_URI} !^/file1.html$
# exclude folders
RewriteCond %{REQUEST_URI}  !(folder1|folder2) [NC]

注意:替换文件 1 和文件夹 1、文件夹 2

最新更新