1
我有2個域指向同一個目錄,現在我想重定向一些URL到一個特定的域,其餘的應該在主域。htaccess重定向特定的URL到不同的域
我有一個域名www.xyz.com這是主域名網站將打開這個域名,從這個域名我想重定向特定的URL到不同的域名,所以如果有人打開www.xyz.com/a/theatre那麼它應該重定向到www.abc.com/a/theatre。現在,如果有人點擊URL中沒有「/ a /影院」的網址,就會從相同的這個新網域重新導向回主網域。因此,如果有人開www.abc.com/a/classes那麼它應該重定向到www.xyz.com/a/classes
我用波紋管的規則,但不能正常工作,
RewriteCond %{HTTP_HOST} ^www.xyz.com$ [NC]
RewriteCond %{REQUEST_URI} ^/a/theatre$
RewriteRule (.*)$ http://www.abc.com/a/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.abc.com$ [NC]
RewriteCond %{REQUEST_URI} !^/a/theatre
RewriteRule (.*)$ http://www.xyz.com/a/$1 [NC,L,R=301]
任何幫助表示讚賞。 謝謝!
這裏是我的htaccess的所有代碼,我已經在這個域上安裝了Joomla。
Options -Indexes
RewriteEngine on
RewriteBase /seo
RewriteCond %{HTTP_HOST} ^www.mcleancenter.org$ [NC]
RewriteCond %{REQUEST_URI} ^/seo/alden-theatre$
RewriteRule ^/?seo/(.*)$ http://www.aldentheatre.org/seo/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.aldentheatre.org$ [NC]
RewriteCond %{REQUEST_URI} !^/seo/alden-theatre
RewriteRule ^/?seo/(.*)$ http://www.mcleancenter.org/seo/$1 [NC,L,R=301]
########## Begin - Joomla! core SEF Section
#
#RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section
感謝您的快速回復喬恩。我在兩條規則中都添加了^ /?a /,但兩者都不起作用。 –
@AmbrishDave是不是在文檔根目錄下的htaccess文件中的這些規則? –
這是在htaccess文件中,並且此文件位於「a」文件夾中。 –