【问题标题】:HTAccess Rewrite affecting other files in the Root?HTAccess Rewrite 会影响 Root 中的其他文件吗?
【发布时间】:2018-04-06 16:48:42
【问题描述】:

我在一个包含我的其他网站的 1and1 共​​享服务器上。

在根目录下,我有一个 HTAccess 文件,以 ID 作为参数重写一个查看照片的 php 文件。

RewriteEngine On
RewriteRule ^([^/d]+)\.html?$ /photography/albums/viewphoto.php?id=$1 [QSA,NC,L]

示例: 当前网址: http://www.example.com/photography/albums/viewphoto.php?id=C01-A01-P01

Desired URL:
http://www.example.com/C01-A01-P01.html

所有用于重写 URL 的工作,但位于根目录中的 html 文件已停止包括我的 PHP 代码函数和保存在 .inc 文件中的变量。

我是否在对单个文件进行特定的重写时遗漏了某些内容,或者在重写时缺少选项?

【问题讨论】:

    标签: php .htaccess mod-rewrite


    【解决方案1】:

    您需要使用 RewriteCond 从 Rewrite 中排除现有文件,

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)\.html?$ /photography/albums/viewphoto.php?id=$1 [QSA,NC,L]
    

    【讨论】:

      猜你喜欢
      • 2016-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-14
      • 2017-02-28
      • 2015-10-02
      • 2019-04-01
      • 2023-03-27
      相关资源
      最近更新 更多