htaccess重定向不适用于内页/文件夹

时间:2017-01-12 03:25:36

标签: .htaccess redirect

好的,所以我从一个域到另一个域都有一堆htaccess重定向,这大部分工作正常。但是,这个特定的链接并不起作用:

http://giccampers.com.au/general-trailers/tipper-trailer/

应该让人们访问这个网站:

http://blackseriescampertrailers.com.au/

如果你转到http://giccampers.com.au/的主域,它会重定向。但我似乎无法让任何其他网页从该域重定向。

这是我所得到的(我没有设置这些,顺便说一下):

RewriteCond %{HTTP_HOST} ^giccampers.com.au [NC]
RewriteRule ^(.*)$ http://blackseriescampertrailers.com.au/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.giccampers.com.au [NC]
RewriteRule ^(.*)$ http://blackseriescampertrailers.com.au/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^giccampers\.com\.au$ [OR]
RewriteCond %{HTTP_HOST} ^www\.giccampers\.com\.au$
RewriteRule ^/?$ "http\:\/\/www\.blackseriescampertrailers\.com\.au\/" [R=301,L]

RewriteCond %{HTTP_HOST} ^www.giccampers.com.au [NC]
RewriteRule ^(.*)$ http://blackseriescampertrailers.com.au/$1 [L,R=301]

redirect 301 /general-trailers/tipper-trailer/ http://blackseriescampertrailers.com.au/

任何帮助都会很棒!

1 个答案:

答案 0 :(得分:0)

使用此

$namespace = 'Admin\\Controller\\';
$matchController = $e->getRouteMatch()->getParam('controller');

if( $namespace === substr($matchController, 0, strlen($namespace))
{
     // check here if user is logged in.
}
else {
     // not an admin controller, do nothing.
}

RedirectMatch 301 http://giccampers.com.au/general-trailers/tipper-trailer/ http://blackseriescampertrailers.com.au/

RedirectMatch 301 /general-trailers/tipper-trailer/ http://blackseriescampertrailers.com.au/

RedirectMatch 301 /tipper-trailer$ http://blackseriescampertrailers.com.au/