[英]Redirecting folder from one domain to another using .htaccess 301 redirect
我正在嘗試進行重寫,以便將目錄及其所有文件和子目錄從一個域重定向到另一個域。
這是我想要實現的目標:
olddomain.com/oldfolder/*
至
http://newdomain.com/newfolder/*
目前,我正在使用以下內容:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$
RewriteRule (.*) http://newdomain.com/newfolder/$1 [L,R=301]
這適用於www.olddomain.com,但不適用於olddomain.com。 實現此目標的最佳方法是什么?
非常感謝你的幫助。
用以下代碼替換代碼:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^oldfolder/(.*)$ http://newdomain.com/newfolder/$1 [L,R=301,NC]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.