【发布时间】:2017-08-29 13:56:03
【问题描述】:
我需要拒绝所有排除的 URL 的访问:
我的域名/文件名.html
并将此请求重定向到:
我的域名/index.php?page=filename.html
并且用户应该在地址栏中看到:
我的域名/文件名.html
我希望所有样式和 js 脚本都能正常工作。
我该怎么做?
我正在尝试这个:
ErrorDocument 404 /
ErrorDocument 403 /
RewriteEngine On
RewriteBase /
RewriteRule ^(\w+)(?=\.).html$ index.php?page=$1.html
#if the request is for existent dirs, forbid the request
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !^/?$
RewriteRule ^ - [R=403,L]
RewriteCond %{REQUEST_URI} !^/?$
RewriteRule !^index.php$ - [R,F,L]
Options All -Indexes
我有服务器错误 500。
如果没有“Options All -Indexes”,js 文件将无法加载并且样式不起作用。
【问题讨论】: