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
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:
https://httpd.apache.org/docs/current/rewrite/intro.html
https://httpd.apache.org/docs/current/mod/mod_rewrite.html
I am new to .htaccess
I am using apache rewrite to give access to virtual directories
following code works
RewriteRule ^maindir/subdir/prog1.php?$ prog1.php?schoolid=12 [L]
RewriteRule ^maindir/subdir/prog2.php?$ prog2.php?schoolid=12 [L]
RewriteRule ^maindir/subdir/prog3.php?$ prog3.php?schoolid=12 [L]
RewriteRule ^maindir/subdir/prog4.php?$ prog4.php?schoolid=12 [L]
RewriteRule ^maindir/subdir/prog5.php?$ prog5.php?schoolid=12 [L]
RewriteRule ^maindir/subdir/prog6.php?$ prog6.php?schoolid=12 [L]
but,
Instead of writing htacess code for each program prog1.php, prog2.php etc
can i use wild card...
Need your help
so that
https://abcd.com/maindir/subdir/anyprogram.com
will be actually executes
https://abcd.com/anyprogram.com
I tried (so as to use wild card in htaccess)
RewriteRule ^maindir/subdir/(.*)$ 1?schoolid=12 [R,L]
RewriteRule ^maindir/subdir/? https://abcd.com/?schoolid=12 [L,NE,R=301]
RewriteRule ^maindir/subdir/?$ $1?schoolid=12 [L,NE,R=301]
but failed
I use this code for R301 for 1 depth of category.For example I want redirect http://sitesample.ltd/new/mynews to http://sitesample.ltd/new/this is my code:
RewriteRule ^mynews/(.+)$ http://sitesample.ltd/new/$1 [R=301,L]
And I want remove depth 2 and 3 from url. For example redirect http://sitesample.ltd/new/mynews/photo to http://sitesample.ltd/new/.I try this but not work:
RewriteRule ^mynews/(.+)/?$ http://sitesample.ltd/new/$2 [R=301,L]
RewriteRule ^mynews/(.+)/(.+)/?$ http://sitesample.ltd/new/$3 [R=301,L]
Another try but no luck:
RewriteRule ^mynews/([^/]+)/?$ http://sitesample.ltd/new/$2 [R=301,L]
RewriteRule ^mynews/(.+)/([^/]+)/?$ http://sitesample.ltd/new/$3 [R=301,L]
If you try to do that:
mynews/xxxx -> http://sitesample.ltd/new/xxxx
mynews/yyyy/xxxx -> http://sitesample.ltd/new/xxxx
mynews/zzzz/yyyy/xxxx -> http://sitesample.ltd/new/xxxx
You can do that:
RewriteRule ^mynews/([^/]+)/?$ http://sitesample.ltd/new/$1 [R=301,L]
RewriteRule ^mynews/[^/]+/([^/]+)/?$ http://sitesample.ltd/new/$1 [R=301,L]
RewriteRule ^mynews/[^/]+/[^/]+/([^/]+)/?$ http://sitesample.ltd/new/$1 [R=301,L]
Or only this:
RewriteRule ^mynews/(?:[^/]+/){0,2}([^/]+)/?$ http://sitesample.ltd/new/$1 [R=301,L]
I'm redirecting an old domain (jeans-vintage.com) to a new one (destock-vintage.com). Here is a snippet of my .htaccess :
RewriteRule ^/$ http://www.destock-vintage.com/ [R=301,NE,NC,L]
RewriteRule ^/jeans-vintage$ http://www.destock-vintage.com/ [R=301,NE,NC,L]
# HOMMES
RewriteRule ^70-polos$ http://www.destock-vintage.com/24-polos-vintage? [R=301,NE,NC,L]
RewriteRule ^68-hommes$ http://www.destock-vintage.com/7-vetements-vintage-homme? [R=301,NE,NC,L]
RewriteRule ^69-tous-les-$ http://www.destock-vintage.com/7-vetements-vintage-homme? [R=301,NE,NC,L]
RewriteRule ^71-t$ http://www.destock-vintage.com/23-t-shirts-vintage? [R=301,NE,NC,L]
RewriteRule ^72-c$ http://www.destock-vintage.com/25-chemises-vintage? [R=301,NE,NC,L]
RewriteRule ^73-pulls$ http://www.destock-vintage.com/22-pulls-vintage? [R=301,NE,NC,L]
RewriteRule ^74-bermudas-et-shorts$ http://www.destock-vintage.com/55-shorts-bermudas-vintage? [R=301,NE,NC,L]
RewriteRule ^75-pantalo$ http://www.destock-vintage.com/26-pantalons-vintage? [R=301,NE,NC,L]
RewriteRule ^76-jeans$ http://www.destock-vintage.com/9-jeans-vintage? [R=301,NE,NC,L]
...
What I want to achieve is redirecting every URL that is not specifically mentioned in this htaccess to the new domain root destock-vintage.com.
For example when I go to jeans-vintage.com/70-polos it goes well to destock-vintage.com/24-polos-vintage.
But if I go to this URL http://www.jeans-vintage.com/panier?add&id_product=3460&token=43e9dbbf254328614bc7b9512e3948e6 it stays on jeans-vintage.com and doesn't redirect to destock-vintage...
I hope you understand :)
Thanks in advance !
Have your rules like this with a CATCH ALL rule in the end. That end rule will only fire when URI doesn't match any of the top rules.:
# HOMMES
RewriteRule ^70-polos$ http://www.destock-vintage.com/24-polos-vintage? [R=301,NE,NC,L]
RewriteRule ^68-hommes$ http://www.destock-vintage.com/7-vetements-vintage-homme? [R=301,NE,NC,L]
RewriteRule ^69-tous-les-$ http://www.destock-vintage.com/7-vetements-vintage-homme? [R=301,NE,NC,L]
RewriteRule ^71-t$ http://www.destock-vintage.com/23-t-shirts-vintage? [R=301,NE,NC,L]
RewriteRule ^72-c$ http://www.destock-vintage.com/25-chemises-vintage? [R=301,NE,NC,L]
RewriteRule ^73-pulls$ http://www.destock-vintage.com/22-pulls-vintage? [R=301,NE,NC,L]
RewriteRule ^74-bermudas-et-shorts$ http://www.destock-vintage.com/55-shorts-bermudas-vintage? [R=301,NE,NC,L]
RewriteRule ^75-pantalo$ http://www.destock-vintage.com/26-pantalons-vintage? [R=301,NE,NC,L]
RewriteRule ^76-jeans$ http://www.destock-vintage.com/9-jeans-vintage? [R=301,NE,NC,L]
# CATCH ALL rule
RewriteRule ^ http://www.destock-vintage.com/ [R=301,L]
If I understand you correctly, you just have to put a last rule catching all the URIs at the end of your existing rules:
RewriteRule ^ http://www.destock-vintage.com/ [R=301,NE,NC,L]
This will not compete with the other rules because every other rule has the "LAST" option [L] (so if any rule match before the "catch all" rule, no rule will be executed after that).
Regards
I want to remove the slash of 1 and only 1 url
this snippet will remove them all
# Remove the trailing slash
RewriteCond %{HTTP_HOST} ^(www.)?example\.com$ [NC]
RewriteRule ^(.+)/$ http://www.example.com/$1 [R=301,L]
but i just want to change
example.com/changeme/
to
example.com/changeme
any ideas how to change this htaccess i have to only do it on one
You could replace (.+) with (changeme) in RewriteRule:
RewriteRule ^(changeme)/$ http://www.example.com/$1 [R=301,L]
This will only match 'changeme' and not everything.
In this way you can also match multiple URLs, including e.g. 'changeother' and 'foobar':
RewriteRule ^(changeme|changeother|foobar)/$ http://www.example.com/$1 [R=301,L]
How about this?
RewriteRule ^changeme/$ http://www.example.com/changeme [R=301,L]
All you need is (as long as this rewrite is only applied to example.com):
RewriteRule ^changeme/$ changeme [R=301,L]