php - 从重写 htaccess 中排除文件和文件夹
问题描述
我在服务器上安装了 wordpress。我还在服务器上上传了名为 hemanshu 的自定义目录。当我尝试访问其中的文件或通过 url 直接访问文件夹时,它显示 404 file not found 错误。
.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]
注意:替换file1和folder1、folder2
推荐阅读
- mysql - 如何将 select 中的计算用于另一个计算
- python - 无法从具有复杂布局的表中抓取三个字段
- node.js - Node.js - 命令 npm run dev 卡在消息“编译完成。观察文件更改”上
- firebase - 是否可以在 firebase 上运行 graphql 订阅?
- gensim - 如何使用 Gensim 上的预训练模型对单词和短语进行聚类
- css - Mapbox GL 自定义控件应用自定义样式
- rxjs - 如何将这种冷的可观察到的变成热的?
- laravel - 尽管声明了 Laravel 路由,但始终未定义
- angular - Angular 的 BuilderContext.reportStatus 似乎没有向控制台报告任何内容
- python - tf.random.categorical 给出奇怪的结果