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

标签 apache .htaccess redirect

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

到目前为止,这是我尝试过的。它没有用:

RewriteEngine On
RewriteCond %{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]
# or
RewriteRule ^jobs/? http://tz433.tld/about-us/jobs.html [R=301,L]

关于apache - 使用.htaccess将特定的URL重定向到另一个URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31829149/

相关文章:

python - mod_mime_magic : can't read `/opt/python/current/app/application.py'

apache - .htaccess 非 www 到 www 以及 http 到 https 重定向

ios - 在 Swift 中防止 URLSession 重定向

python - Django,重定向到另一个带有数据的 View

apache - 是否可以从 Apache RewriteCond 模式匹配中捕获变量?

apache - org.apache.http.ConnectionClosedException : Premature end of chunk coded message body: closing chunk expected

python - Windows 下 Apache 下无法通过 mod_wsgi 导入 pyodbc

php - www 不重定向到非 www .htaccess Wordpress

.htaccess - mod_rewrite,进行更改时不重写

Apache 从子域重写为 www 但保留所有永久链接