2015-06-03 45 views
1

我嘗試了很多,看着其他職位,但沒有得到它的工作..Wordpress 301帶問號的重定向?從一個域與不同的URL結構的新域名

  1. 我想重定向olddomain.com/?portfolio=這是標題的職位,以newdomain.com/portfolio/newtitle1/

  2. 我想重定向olddomain.com//?portfolio=10689到newdomain.com/portfolio/newtitle2/

  3. 我想檢查mu是否將olddomain.com重定向到newdomain.com設置正確

UPDATE:你的第一個答案,我把它更新到這一點,但仍然沒有工作後:

RewriteCond %{QUERY_STRING} ^portfolio=this-is-the-title-of-the-post$ 
RewriteRule^http://newsite.com/portfolio/newtitle1/? [R=301,L] 

RewriteCond %{QUERY_STRING} ^portfolio=10689$ 
RewriteRule^http://newsite.com/portfolio/newtitle2/? [R=301,L] 

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 
# END WordPress 

# BEGIN 301 Redirects 
Redirect 301 /index.php http://newsite.com 
Redirect 301 /cart/ http://shop.newsite.com/cart/ 
Redirect 301 /my-account/ http://shop.newsite.com/my-account/ 
Redirect 301 /shop/ http://shop.newsite.com/ 
Redirect 301 /portfolio-one-column-standard-style/ http://newsite.com/portfolio/ 
Redirect 301 /home/blog/ http://newsite.com/blog/ 
Redirect 301 /about/ http://newsite.com/about/ 
# END 301 Redirects 

回答

0

在您的.htaccess的頂部試試這條規則:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/

RewriteCond %{QUERY_STRING} portfolio=this-is-the-title-of-the-post 
RewriteRule^http://newsite.com/portfolio/newtitle1/? [R=301,L] 

RewriteCond %{QUERY_STRING} portfolio=10689 
RewriteRule^http://newsite.com/portfolio/newtitle2/? [R=301,L] 

# BEGIN 301 Redirects 
RewriteRule ^(index\.php)?$ http://newsite.com/ [NC,R=301,L] 
RewriteRule ^cart/ http://shop.newsite.com/cart/ [R=301,L] 
RewriteRule ^my-account/ http://shop.newsite.com/my-account/ [R=301,L] 
RewriteRule ^shop/ http://shop.newsite.com/ [R=301,L] 
RewriteRule ^portfolio-one-column-standard-style/ http://newsite.com/portfolio/ [R=301,L] 
RewriteRule ^home/blog/ http://newsite.com/blog/ [R=301,L] 
RewriteRule ^about/ http://newsite.com/about/ [R=301,L] 
# END 301 Redirects 

RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 
# END WordPress 
Make sure to clear your browser cache before you test. 
+0

nope ...似乎不是工作,也不是當我在上面添加'RewriteEngine On'時。它仍然會將olddomain.com/?portfolio=item1-test重定向到newdomain.com/?portfolio=item1-test,而不是newdomain.com/portfolio/item1/ – Joost

+0

明確的緩存,將這些確切的四行放在頂部。 htaccess文件後,#BEGIN WordPress和#BEGIN 301重定向...沒有成功 – Joost

+0

更新了我現在使用的代碼 – Joost

0

你忘記在以下規則之前添加RewriteEngine On

RewriteCond %{QUERY_STRING} ^portfolio=this-is-the-title-of-the-post$ 
RewriteRule^http://newsite.com/portfolio/newtitle1/? [R=301,L] 

RewriteCond %{QUERY_STRING} ^portfolio=10689$ 
RewriteRule^http://newsite.com/portfolio/newtitle2/? [R=301,L]