【问题标题】:htaccess redirect won't work if file doesn't exist如果文件不存在,htaccess 重定向将不起作用
【发布时间】:2011-06-12 09:37:46
【问题描述】:

服务器:Debian 和 apache2;

var/www: 项目 -> /samba/project/

桑巴/项目: 索引.php .htaccess 测试.php

htaccess:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /project/

RewriteCond %{REQUEST_URI} !index.php.*
RewriteRule ^(.*)$ index.php [L]

localhost/ -> 有效

localhost/index.php -> 有效

localhost/test.php -> 有效(重定向到 index.php 有效)

http://localhost/asdsads -> 不起作用(错误 403)

为什么?

谢谢

【问题讨论】:

  • 错误日志显示:“不允许符号链接或链接目标不可访问”但 www-data 具有权限

标签: apache .htaccess apache2 debian


【解决方案1】:

尝试将最后两行更改为

RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^ index.php [L]

第一行检查请求的 URL 是否没有映射到物理文件,第二行将每个请求(总是有一个开头,用 ^ 表示)重写为 index.php。

【讨论】:

  • 谢谢我们解决了所有问题,windows和debian之间的文件夹共享存在一些问题
猜你喜欢
  • 2010-10-14
  • 2021-12-24
  • 1970-01-01
  • 1970-01-01
  • 2015-11-08
  • 1970-01-01
  • 2015-03-07
  • 2015-08-01
  • 1970-01-01
相关资源
最近更新 更多