【问题标题】:Wordpress rewrite : Redirect page to Home pageWordpress 重写:将页面重定向到主页
【发布时间】:2012-07-07 03:22:11
【问题描述】:

我有一个带有 url http://mydomain.com/home/ 的 wp 页面。我想使用 htaccess 将其重定向到 http://mydomain.com/

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /
   RewriteRule ^index\.php$ - [L]
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^home/$ index.php [L]    #This is my attempt to redirect; not working.
   RewriteRule . /index.php [L]
</IfModule>

【问题讨论】:

    标签: wordpress redirect


    【解决方案1】:

    在默认 wp htaccess 规则集之外编写规则。试试下面:

    RewriteRule ^home/(.*) http://mydomain.com/$ [L]
    
    <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteBase /
       RewriteRule ^index\.php$ - [L]
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule . /index.php [L]
    </IfModule>
    

    【讨论】:

      【解决方案2】:

      只需在 wordpress 阅读设置中将主页设置为首页即可。应该不用 apache mod_rewrite 就可以了

      【讨论】:

        【解决方案3】:

        使用 301 重定向,是永久性的,有利于 SEO

        RedirectMatch 301 ^/home($|/.*) $1
        

        在我的本地主机上测试过这个:)

        /主页 /家/ /home/?blahblah

        这一切都重定向到/保留正确的部分查询字符串

        【讨论】:

          猜你喜欢
          • 2017-07-09
          • 2015-05-30
          • 1970-01-01
          • 2018-07-10
          • 2017-07-23
          • 2015-04-19
          • 1970-01-01
          • 2023-04-08
          • 2011-05-24
          相关资源
          最近更新 更多