使用.htaccess将特定的URL重定向到另一个URL

编程入门 行业动态 更新时间:2024-10-27 23:25:03
本文介绍了使用.htaccess将特定的URL重定向到另一个URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想要一个别名,并将URL tz433.tld / jobs / 重定向到页面 tz433.tld / about-us / jobs / 。

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 (.*) tz433.tld/about-us/jobs.html [R=301,L]

问题是,在此根路径中有多个域,因为它是一个多站点typo3安装。因此,诸如将 / jobs 重定向到 / about-us / jobs 之类的东西不起作用,因为它只会发生

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).

下一个特定的内容是 www.tz433.tld 自动重定向到 tz433.tld 。因此,它也应与 www.tz433.tld / jobs / 和 tz433.tld / jobs 一起使用。两者都应重定向到 tz433.tld / about-us / jobs.html 。

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.

如何成功实现?

推荐答案

如果您希望仅在域为 tz433.tld 时执行规则,则需要以下条件:

If you want the rule to only execute when the domain is "tz433.tld", you need this condition:

RewriteCond %{HTTP_HOST} ^(www\.)?tz433\.tld

并重定向 jobs / 和 jobs

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/? tz433.tld/about-us/jobs.html [R=301,L]

更多推荐

使用.htaccess将特定的URL重定向到另一个URL

本文发布于:2023-10-04 19:45:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1467206.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   htaccess   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!