htaccess重定向到没有页面ID和新目录的URL

时间:2017-12-15 20:01:32

标签: .htaccess redirect

我有这个网址。

https://www.example.com/media-center/3635-cybersecurity-data-privacy-proposed

如何在没有id /连字符和新目录名的情况下重定向到此URL?

https://www.example.com/news-insights/cybersecurity-data-privacy-proposed

我有这段代码,但它不会改变目录名称。

| id | skill_1 | skill_1_primary | skill_1_backup |    skill_2 | skill_2_primary | skill_2_backup |    skill_3 | skill_3_primary | skill_3_backup |    skill_4 | skill_4_primary | skill_4_backup | skill_5 | skill_5_primary | skill_5_backup |
|----|---------|-----------------|----------------|------------|-----------------|----------------|------------|-----------------|----------------|------------|-----------------|----------------|---------|-----------------|----------------|
|  1 |   Excel |               Y |         (null) | PowerPoint |               Y |         (null) |       Word |               Y |              Y |     (null) |          (null) |         (null) |  (null) |          (null) |         (null) |
|  2 |   Excel |               Y |         (null) |    Outlook |               Y |         (null) | PowerPoint |               Y |              Y |       Word |               Y |         (null) |  (null) |          (null) |         (null) |
|  3 |   Excel |               Y |         (null) | PowerPoint |               Y |         (null) |       Word |               Y |         (null) |     (null) |          (null) |         (null) |  (null) |          (null) |         (null) |
|  4 |  Access |               Y |              Y |      Excel |               Y |              Y |    Outlook |               Y |         (null) | PowerPoint |               Y |         (null) |    Word |               Y |         (null) |
|  5 |   Excel |               Y |         (null) |    Outlook |               Y |         (null) | PowerPoint |               Y |         (null) |       Word |          (null) |              Y |  (null) |          (null) |         (null) |

1 个答案:

答案 0 :(得分:0)

您可以使用此规则:

RedirectMatch 301 ^/media-center/\d+-(.+)$ /news-insights/$1

确保清除浏览器缓存或使用新浏览器进行测试。