简体   繁体   English

重写 - 重定向所有没有index.php

[英]Rewrite - Redirecting all without index.php

I have a index.php file blank and Loader.php file in my root folder and have the following code: 我在我的根文件夹中有一个index.php文件空白和Loader.php文件,并具有以下代码:

RewriteEngine On
RewriteBase /
RewriteRule . Loader.php [L]

When i remove the index.php file (it has nothing) Rewrite does not work and the Apache back an "Index of". 当我删除index.php文件(它什么都没有)重写不起作用,Apache回“索引”。

How to delete the "index.php" and keep Rewrite working? 如何删除“index.php”并保持Rewrite工作?

Try changing your rule's pattern from . 尝试更改您的规则模式. to ^ . ^ The . . means there must be at least one character in the request. 表示请求中必须至少有一个字符。 If you try loading / (which is a blank request), the . 如果您尝试加载/ (这是一个空白的请求), . pattern won't match it. 模式不匹配。 Then, because you have an index file, that gets mapped and the index file gets put through the rules. 然后,因为你有一个索引文件,它被映射,索引文件通过规则。 The second time around . 第二次. matches because there's characters in the request. 匹配,因为请求中有字符。

RewriteRule ^ Loader.php [L]

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

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