Redirect in .htaccess makes me cracy

Viewed 17

Following ws call https://training-deluxe.de/nlpdocs/podcast/feed/ should be redirected to podcast hoster podigee

.htaccess

RewriteEngine On
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^(.*)$ https://www.training-deluxe.de/$1 [R=301,L]
RewriteCond %{SERVER_PORT} !^443$

#Whats wrong with the next line
RewriteRule /nlpdocs/podcast/feed/ https://coachingundwissenschaft.podigee.io/feed/mp3 [R=301,L]

RewriteRule /coaching_ausbildung/gesundheitscoach_somatic_release_achtsamkeit.html https://rubin-institut.de/health-practitioner-und-gesundheitscoach/ [L,R=301] 

RewriteRule ^(nlpdocs/.*)$ https://www.rubin-institut.de/$1 [R=301,L]
RewriteRule ^(.*)$ https://rubin-institut.de/$1 [L,R=301] 

Redirect goes to rubin-institut/nlpdocs/podcast...

I cant get the clue

1 Answers

There's a couple of issues...

RewriteEngine On
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^(.*)$ https://www.training-deluxe.de/$1 [R=301,L]
RewriteCond %{SERVER_PORT} !^443$

You need to remove that 2nd/last RewriteCond directive above as that will break the rule that follows. RewriteCond directives are conditions that apply to the first RewriteRule directive that follows.

#Whats wrong with the next line
RewriteRule /nlpdocs/podcast/feed/ https://coachingundwissenschaft.podigee.io/feed/mp3 [R=301,L]

The first argument to the RewriteRule directive takes a regular expression (regex) - as you've used in later rules. It is not a simple URL-path. And, importantly, in .htaccess the URL-path matched by the RewriteRule pattern does not start with a slash. (You have omitted the slash prefix in the later rule that is evidentally "working".)

It should be like this instead:

RewriteRule ^nlpdocs/podcast/feed/$ https://coachingundwissenschaft.podigee.io/feed/mp3 [R=301,L]

You will need to clear your browser cache before testing since the erroneous 301 (permanent) redirect will have been cached by the browser. Test first with 302 (temporary) redirects to avoid caching issues.

You will also need to check the rule that follows, as that looks like it would have the same problem.

Reference:

Related