.htaccess 文件重定向以相同字符串开头的页面

发布于 2025-01-15 21:12:29 字数 469 浏览 2 评论 0原文

我正在尝试重定向两个页面,并且使用以下代码

RewriteRule projects/(.+) /Pages/Shop/SinglePortfolio.php?ID=$1 [NC,L]
RewriteRule projects$ /Pages/Shop/Portfolio.php [NC,L]

第一页将类似于 /projects/project-no-one 第二个是 /projects

此规则当前显示 Portfolio.php 页面,但不显示 SinglePortfolio.php (404) 如果我恢复规则,则显示 SinglePortfolio.php 页面,但不显示 SinglePortfolio.php (404)

尝试

  • 在项目 $ 处不使用 $
  • 其他正则表达式
  • 将项目/(.+) 更改为项目/(.+),但前缀是相同,这似乎会引起问题。

I am trying to redirect two pages and i am using thw following code

RewriteRule projects/(.+) /Pages/Shop/SinglePortfolio.php?ID=$1 [NC,L]
RewriteRule projects$ /Pages/Shop/Portfolio.php [NC,L]

The first page will be like /projects/project-no-one
The second will be the /projects

This rule is currenty shows the Portfolio.php page, but not the SinglePortfolio.php (404)
If i revert the rules shows the SinglePortfolio.php page, but not the SinglePortfolio.php (404)

Tried

  • Without the $ at projects$
  • Other regular expressions
  • changing the projects/(.+) to project/(.+) but the prefix is the same and that seems to cause a problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文