Redirect a specific url to another url with .htaccess

I would like to have an alias and redirect the tz433.tld/jobs/ URL to the tz433.tld/about-us/jobs/ page.

This is what I tried far; this did not work:

 RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.tz433\.tld/jobs/$ RewriteRule (.*) http://tz433.tld/about-us/jobs.html [R=301,L] 

The problem is that there are several domains in this root path because it is a multi-user installation of typo3. So, something like "redirect /jobs to /about-us/jobs " does not work, because it should only happen for a specific domain (tz433).

The following feature of www.tz433.tld automatically redirected to tz433.tld . Therefore, it should also work with www.tz433.tld/jobs/ and tz433.tld/jobs . Both should be redirected to tz433.tld/about-us/jobs.html .

How can I achieve this successfully?

+8
redirect apache .htaccess
source share
2 answers

If you want the rule to be executed only if the domain is "tz433.tld", you need the following 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 them:

 RewriteRule ^jobs/? /about-us/jobs.html [R=301,L] # or RewriteRule ^jobs/? http://tz433.tld/about-us/jobs.html [R=301,L] 
+8
source share

If someone is just interested in a simple redirect, you can try this:

  Redirect /URL URLtoRedirect 

eg

  Redirect /old-url https://mywebsite.com/new-url 
0
source share

All Articles