如何为单个页面重写插件域的 URL



我在 stonycreekgallery.com.au 有一个WordPress网站,它 redpeppergallery.com.au 作为插件域(更正:"停放域",抱歉)。

我希望访问者主要以 stonycreekgallery.com.au 的方式浏览网站,但每当他们访问单个页面 http://stonycreekgallery.com.au/red-pepper-gallery/时,我希望将URL重写为 redpeppergallery.com.au。

我发现了一个类似的问题(未回答),并尝试了以下方法:

RewriteCond %{HTTP_HOST} ^(www.)?redpeppergallery.com.au$ [NC]
RewriteCond %{REQUEST_URI} !^/red-pepper-gallery/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /red-pepper-gallery/ [L]
RewriteCond %{HTTP_HOST} ^(www.)?redpeppergallery.com.au$ [NC] 
RewriteRule ^(/)?$ red-pepper-gallery/ [L] 

这些规则当前在域中处于活动状态。

有什么指示给我吗?!蒂亚、蒂姆·


编辑:一些澄清...

  • 只有一个站点,在WordPress站点上运行
  • Redpeppergallery的链接在WordPress中设置为指向 redpeppergallery.com.au
  • 红辣椒画廊是一个停放的域名/域名别名(上面我错误地将其称为插件)
  • redpeppergallery.com.au 应该直接转到 http://stonycreekgallery.com.au/red-pepper-gallery/

以下工作完成了一半 - 它将红辣椒画廊直接带到正确的页面:

RewriteCond %{HTTP_HOST} ^(www.)?redpeppergallery.com.au$ [NC]
RewriteCond %{REQUEST_URI} !^/red-pepper-gallery/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://stonycreekgallery.com.au/red-pepper-gallery/ [L]

任务的第二部分是:在页面 stonycreekgallerycom.au/red-pepper-gallery/(仅此页面)上时:将URL显示为 redpeppergallery.com.au..这是我不确定的...从那以后我尝试了:

RewriteCond   %{REQUEST_FILENAME}   ^stonycreekgallery.com.au/red-pepper-gallery/?$         [NC]
RewriteRule   http://redpeppergallery.com.au/  [R=301]

我预计迟早会陷入循环,但它还没有发生:)我尝试过的最后一个片段的变化没有效果......

尝试将其放入 stonycreekgallery.com.au 域的文档根目录中的 htaccess 文件中:

Redirect 301 /red-pepper-gallery http://redpeppergallery.com.au/

如果您不想重定向,但希望浏览器的URL地址栏保持在 stonycreekgallery.com.au 那么它将取决于您的配置。

如果两个域都停放在同一个文档根目录,这意味着例如http://stonycreekgallery.com.au/http://redpeppergallery.com.au/都从目录/something/www/root提供,那么您可以在文档根目录的htaccess文件中执行此操作:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?stonycreekgallery.com.au$ [NC]
RewriteRule ^red-pepper-gallery/(.*) /$1 [L]
否则,如果一个文档根目录

位于另一个文档根目录内,例如,http://stonycreekgallery.com.au/从目录/something/www/root提供,但http://redpeppergallery.com.au/从目录/something/www/root/gallery提供,那么您将执行以下操作:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?stonycreekgallery.com.au$ [NC]
RewriteRule ^red-pepper-gallery/(.*) /gallery/$1 [L]

如果这两个域是从完全独立的文档根目录提供的,则需要使用 [P] 标志,但这仅在加载mod_proxy时才有效:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?stonycreekgallery.com.au$ [NC]
RewriteRule ^red-pepper-gallery/(.*) http://redpeppergallery.com.au/$1 [P,L]

最新更新