首页 文章

使用.htaccess将旧的wordpress网站页面重定向到新的php网站网址

提问于
浏览
1
  • 我有一个网站'example.com',最初是在wordpress中,但我不得不把它移到php .

  • 现在我的网站是在php . 现在的问题是,我尝试重定向网址,例如: http://www.example.com/about-mysite/ ,使用.htaccess文件中的Redirect 301重定向到我的新网址 .

  • 假设我的旧页面是/ about-example /,我将其重定向为,

Redirect 301 /about-mysite/ http://www.example.com/about-example.php

但它没有被重定向 .

1 回答

  • 1

    将此重定向规则放在.htaccess before WP rules 的顶部:

    Options -MultiViews
    RewriteEngine On
    
    RewriteRule ^(about-kankaria-eye-hospital)/?$ /$1.php [L,NC,R=301]
    

    建议 generic redirect rule

    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^([^.]+)/?$ /$1.php [L,NC,R=301]
    

相关问题