【问题标题】:Rewrite file from another directory从另一个目录重写文件
【发布时间】:2015-04-19 11:53:25
【问题描述】:

我正在尝试重写另一个目录中的文件,但它给出了错误。

找不到

在此服务器上找不到请求的 URL /admin/posts/edit/1。

此外,在尝试访问时遇到 404 Not Found 错误 使用 ErrorDocument 来处理请求。

/public_html
    /admin
         /.htaccess
         /posts

我需要从这个www.example.com/admin/posts/edit.php?id=1做这个www.example.com/admin/posts/edit/1

我的 .htaccess 中有这段代码:

RewriteEngine On

RewriteRule ^edit/([0-9a-zA-Z]+) /admin/posts/edit.php?id=$1 [NC,L]

【问题讨论】:

  • /admin/posts/edit.php?id=$1...是的..它存在

标签: php apache .htaccess mod-rewrite url-rewriting


【解决方案1】:

创建一个文件/admin/.htaccess 并放置此规则:

Options -MultiViews
RewriteEngine On
RewriteBase /admin/

RewriteRule ^posts/edit/([0-9a-z]+)/?$ posts/edit.php?id=$1 [NC,L,QSA]

【讨论】:

  • 我不能这样做,因为我有用户、类别等文件夹。我必须让它充满活力
猜你喜欢
  • 2014-06-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-02
  • 2017-07-20
  • 2012-02-15
相关资源
最近更新 更多