【发布时间】:2021-08-07 03:40:54
【问题描述】:
如果请求 uri 不包含 api 或列表,我目前正在尝试制作 htaccess 以在 new/ 中查找文件。我试图做这样的事情,但它显示 403 错误。有没有更简单的过滤方法,或者?
RewriteEngine on
RewriteCond %{REQUEST_URI} /api/ [NC]
RewriteCond %{REQUEST_URI} /list/ [NC]
RewriteRule ^/(.*)$/ new/$1 [L, R]
完整的htaccess代码
#remove html file extension
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]
#remove php file extension
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
#set max post size
php_value memory_limit 2048M
php_value max_execution_time 3000
php_value max_input_time 6000
php_value post_max_size 800M
php_value upload_max_filesize 200M
#Caching schema
<FilesMatch "\.(png|svg|css|eot|ttf|woff|woff2|otf|js|css)$">
Header set Cache-Control "public, max-age=86400000"
</FilesMatch>
DirectoryIndex index.html
#Custom 404 errors
ErrorDocument 404 /404.html
#Prevent viewing of .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
<Files error_log>
order allow,deny
deny from all
</Files>
#Prevent directory listings
Options All -Indexes
【问题讨论】:
-
new/目录中有 .htaccess 吗? -
不,我没有新的/
-
好的,你能提供完整的 .htaccess 吗
-
@anubhava 你在这里