Plugin Author
AITpro
(@aitpro)
Also is that the htaccess redirect code that that Redirection plugin is creating/generating? That code could be problematic. Typically for redirects you would use htaccess code like this below instead using the RewriteRule directive:
Important Note: This code is being forced into 2 lines and should be only 1 continuous line of code.
RedirectMatch 301 ^/business-coach/$ https://www.example.com/business/
Thread Starter
sally
(@sallyruchman)
htaccess Snippet added from Redirection Plugin was this:
<IfModule mod_rewrite.c>
RewriteRule ^business-coach$ https://domain.com/business/ [R=301,L]
</IfModule>
I tried yet your snippet without <IfModule mod_rewrite.c> and its working.
RedirectMatch 301 ^/business-coach/$ https://www.example.com/business/
Just saw that when entering url https://domain.com/business-coach without slash I get a 404 I guess I have just to adapt your snippet to ignore the slash
RedirectMatch 301 ^/business-coach$ https://www.example.com/business/
Plugin Author
AITpro
(@aitpro)
Well the difference is using the RedirecMatch directive vs the RewriteRule directive and not so much using the IfModule directive.
Yes, removing the trailing slash will work, but use caution because that says to match everything from/to /business-coach. Let’s say you have another URL this is something like this /business-coach-blah. That redirect rule will also match the portion of that URL. ie /business-coach. Typically you want to match all the way to the last trailing slash because that makes the particular URI completely unique. /business-coach/ would not match /business-coach-blah/.
Thread Starter
sally
(@sallyruchman)
When adding the redirect adapted like this:
RedirectMatch 301 ^/business-coach$ https://www.example.com/business/
and checking then the redirect without slash I get a 404, when entering the url with slash the redirect works… do I need for redirection same url with and without url 2 Redirect Rules?
Plugin Author
AITpro
(@aitpro)
Why would you want to match /business-coach without a trailing slash? Typically you would always want to match up to the last trailing URI slash. That is the standard URI matching pattern for redirects.
-
This reply was modified 6 years, 3 months ago by
AITpro.
Plugin Author
AITpro
(@aitpro)
You could do this instead. This rule says to match “nothing” after coach or match a trailing slash after coach.
RedirectMatch 301 ^/business-coach(|/)$ https://www.example.com/business/
-
This reply was modified 6 years, 3 months ago by
AITpro.
-
This reply was modified 6 years, 3 months ago by
AITpro.
Plugin Author
AITpro
(@aitpro)
I updated my comments in my previous reply. The redirect rule in my previous reply is actually exactly what you want to use to match the URI with and without a trailing slash.
Thread Starter
sally
(@sallyruchman)
Great, Thanks a Lot for your Time and Help on this Issue
Best regards
Sally