繁体   English   中英

将所有URL重写为index.php(白名单除外)

[英]Rewrite all URL to index.php except whitelist

.htaccess我这样写:

AddDefaultCharset UTF-8
RewriteEngine on

RewriteCond $1 !^(index\.php|images|test|css|js|files|wiki|sitemap\.xml|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php/$1 [L]

但是我有两个问题:

  1. http://example.com/ajax/index.php不会转换为http://example.com/index.php/ajax/index.php
  2. 我可以看到任何列入白名单的目录,如何防止这种情况?

尝试这个:

AddDefaultCharset UTF-8
RewriteEngine on

RewriteCond %{REQUEST_URI} !^(index\.php|images|test|css|js|files|wiki|sitemap\.xml|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php/$1 [L]

Options All -Indexes
  • 最后一行应修复列表,在条件中使用请求uri应修复重写。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM