[英]htaccess redirect won't work if file doesn't exist
Server: Debian with apache2; 服务器:Debian和apache2;
var/www: project -> /samba/project/ var / www:project-> / samba / project /
samba/project: index.php .htaccess test.php 桑巴舞/项目:index.php .htaccess test.php
htaccess: htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /project/
RewriteCond %{REQUEST_URI} !index.php.*
RewriteRule ^(.*)$ index.php [L]
localhost/ -> it works 本地主机/->它有效
localhost/index.php -> it works 本地主机/ index.php->它的工作原理
localhost/test.php -> it works (redirect to index.php works) localhost / test.php->它有效(重定向到index.php起作用)
http://localhost/asdsads -> doesn't work (error 403) http:// localhost / asdsads- >不起作用(错误403)
why? 为什么?
thx 谢谢
Try changing your last two lines to 尝试将最后两行更改为
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^ index.php [L]
The first line checks if the requested URL does not map to a physical file, and the second line rewrites every request (which always has a beginning, denoted by ^) to index.php. 第一行检查请求的URL是否未映射到物理文件,第二行将每个请求(始终以^表示的开头)重写为index.php。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.