使用 .htaccess 将特定 url 重定向到另一个 url [英] redirect a specific url to another url with .htaccess
问题描述
我想要一个别名并将 URL tz433.tld/jobs/
重定向到页面 tz433.tld/about-us/jobs/
.>
这是我迄今为止尝试过的;它没有用:
RewriteEngine OnRewriteCond %{HTTP_HOST} !^www\.tz433\.tld/jobs/$RewriteRule (.*) http://tz433.tld/about-us/jobs.html [R=301,L]
问题是,在这个根路径中有多个域,因为它是一个多站点的typo3安装.因此,诸如将 /jobs
重定向到 /about-us/jobs
"之类的操作是行不通的,因为它应该只发生在特定域 (tz433) 上.
接下来是www.tz433.tld
自动重定向到tz433.tld
.所以它也应该适用于 www.tz433.tld/jobs/
和 tz433.tld/jobs
.两者都应该重定向到 tz433.tld/about-us/jobs.html
.
我如何才能成功实现这一目标?
如果你希望规则只在域为"tz433.tld"时执行,你需要这个条件:
RewriteCond %{HTTP_HOST} ^(www\.)?tz433\.tld
并将 "jobs/" 和 "jobs" 重定向到 "tz433.tld/about-us/jobs.html",您可以尝试以下方法之一:
RewriteRule ^jobs/?/about-us/jobs.html [R=301,L]# 或者重写规则 ^jobs/?http://tz433.tld/about-us/jobs.html [R=301,L]
I would like to have an alias and redirect the URL tz433.tld/jobs/
to the page tz433.tld/about-us/jobs/
.
This is what I've tried by far; it didn't work:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.tz433\.tld/jobs/$
RewriteRule (.*) http://tz433.tld/about-us/jobs.html [R=301,L]
The problem is, in this root path there are multiple domains, because it is a multisite typo3 installation. So something like "redirect /jobs
to /about-us/jobs
" isn't working because it should only happen for a specific domain (tz433).
The next specific thing is www.tz433.tld
automatically redirects to tz433.tld
. So it should also work with www.tz433.tld/jobs/
and tz433.tld/jobs
. Both should redirect to tz433.tld/about-us/jobs.html
.
How can I achieve that successfully?
If you want the rule to only execute when the domain is "tz433.tld", you need this condition:
RewriteCond %{HTTP_HOST} ^(www\.)?tz433\.tld
And to redirect "jobs/" and "jobs" to "tz433.tld/about-us/jobs.html", you can try one of these:
RewriteRule ^jobs/? /about-us/jobs.html [R=301,L]
# or
RewriteRule ^jobs/? http://tz433.tld/about-us/jobs.html [R=301,L]
这篇关于使用 .htaccess 将特定 url 重定向到另一个 url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!