簡體   English   中英

使用.htaccess 301將文件夾從一個域重定向到另一個域

[英]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.

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