【问题标题】:Redirect an old URL structure to new URL structure?将旧的 URL 结构重定向到新的 URL 结构?
【发布时间】:2014-05-13 13:37:27
【问题描述】:

我需要将旧结构中的 URL 重定向到新结构。

旧网址:

http://domain.com/index.php?name=PNphpBB2&file=viewtopic&p=28341&highlight=inner#28341

新网址:

http://domain.com/viewtopic.php?p=28341&highlight=inner#28341

如何通过 htaccess 做到这一点?还是我需要在 /index.php 文件中添加一些东西?

提前致谢。

【问题讨论】:

  • 参数name有没有用到?
  • 不再使用name变量。

标签: .htaccess url mod-rewrite redirect permalinks


【解决方案1】:

您可以在根 .htaccess 文件中使用此规则:

RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+index\.php\?name=[^&]*&file=viewtopic&p=([^&]+)&highlight=([^&]+) [NC]
RewriteRule ^ /viewtopic.php?p=%1&highlight=%2#%1 [R=302,L,NE]

【讨论】:

    猜你喜欢
    • 2013-01-07
    • 2012-03-23
    • 2013-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-28
    相关资源
    最近更新 更多