【问题标题】:How to redirect from an old url to a new one after removing the extension through htaccess?通过htaccess删除扩展后如何从旧网址重定向到新网址?
【发布时间】:2015-12-08 18:11:43
【问题描述】:

我正在使用以下 sn-p 删除我的页面的 php 扩展名:

RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [L,R=301]

现在我想做一个旧页面到一个新页面。像http://www.example.com/oldpage 这样的东西应该永久(301)重定向到http://www.example.com/newpage

【问题讨论】:

    标签: php .htaccess mod-rewrite redirect


    【解决方案1】:

    您可以简单地使用重定向匹配:

    RedirectMatch 301 ^/oldpage$ /newpage
    

    【讨论】:

    • RewriteEngine on rewritecond %{http_host} ^example.com [nc] rewriterule ^(.*)$ http://www.example.com/$1 [L,R=301] RedirectMatch 301 ^/oldpage$ /newpage 这就是我尝试过的方法,但它仍在打开旧页面
    • 你可以把这个放在RewriteEngine上面就行
    • 试过但没有成功。仍然打开旧页面
    • 你还有什么规定吗?
    • 就是上面问题中提到的内容。
    猜你喜欢
    • 2021-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-21
    • 1970-01-01
    相关资源
    最近更新 更多