【问题标题】:.htaccess redirect css file to php.htaccess 将 css 文件重定向到 php
【发布时间】:2013-07-07 02:50:33
【问题描述】:

我把我的 file.css 文件重命名为 file.php 并将这段代码添加到新的 php 文件的第一行:

<?php
    session_start();
    header("Content-type: text/css");
?>
/* css content goes here ... */

现在我正在尝试通过 htaccess 将所有请求从 http://puaction.com/css/file.css 重定向到 http://puaction.com/css/file.php 但它不起作用...:/

我的 htaccess 文件有什么问题?

这是我的 .htaccess 文件:

RewriteEngine on
RewriteRule file.css file.php

【问题讨论】:

  • .htaccess在哪里?
  • 我没有看到 .htaccess 文件?
  • 我刚刚添加了我的 htaccess 文件...看看。谢谢!
  • 您的 Apache 配置是否允许您在 .htaccess 文件中更改这些设置?如果是,那么或许可以参考 Apache 关于mod_rewrite 主题的文档:httpd.apache.org/docs/current/rewrite/remapping.html

标签: php css .htaccess redirect rewrite


【解决方案1】:

在文档根目录的 htaccess 文件中,添加:

Redirect 301 /css/file.css /css/file.php

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-08
    • 1970-01-01
    • 2021-02-04
    • 2011-12-26
    • 1970-01-01
    相关资源
    最近更新 更多