簡體   English   中英

WordPress重寫:將頁面重定向到主頁

[英]Wordpress rewrite : Redirect page to Home page

我有一個網址為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>

在默認的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>

只需在wordpress閱讀設置中將首頁設置為首頁即可。 那應該不用apache mod_rewrite

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

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

在我的本地主機上測試了這個:)

/ home / home / / home /?blahblah

這全部重定向到/保留正確的部分查詢字符串

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM