简体   繁体   中英

Wordpress rewrite : Redirect page to Home page

I have a wp page with the url, http://mydomain.com/home/ . I would like redirect it to http://mydomain.com/ using htaccess.

<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>

Write rule outside the default wp htaccess rules set. Try below:

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>

Just set the Home page to your front page in wordpress reading settings. That should do it without apache mod_rewrite

Use 301 redirect, is permanent and is good for SEO

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

Tested this on my localhost :)

/home /home/ /home/?blahblah

this all redirects to / preserving the right portion query strings

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM