sharingsunshine
asked on
Need a Regex URL Ending in a Quotation Mark (")
I need to redirect this url
Thanks,
Randal
https://www.bensherbsplace.com/success_stories_for_pets_sp_195/"
I have tried ^/(.+)/%22$ but there is no match. How can I match a quotation mark?Thanks,
Randal
Try \? instead of the %22 that you have now
ASKER
Thanks for getting back to me. That didn't work and I have left it in place in case that will help you to troubleshoot. Here is what I am matching to.
^/(.+)/\?$
What are you using to do the redirect? A WordPress plugin? htaccess file?
You may be able to match the " character with just \"
Your URL does not contain a question mark? Why would you want to use it then in a regexp?
ASKER
I wouldn't but I was going by what you suggested
Try \? instead of the %22 that you have now
ASKER
I tried the straight " and it didn't work. My host, Kinsta has a redirect tool. What is the encoded value for a "?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can also try ["] to match a double quote.
I suggest you start by getting a redirect working that's almost what you want, and then going from there.
When testing your redirect, ensure you don't use a 301 redirect, as browsers will cache the redirect and cause major problems. 302 is better. This is very important, as you can't get the general public to clear their browser cache once they've cached an incorrect redirect. It will just keep on redirecting them to the wrong place, potentially for months.
So start with something like:
Then start trying to target the double quote. Perhaps firstly try:
When testing your redirect, ensure you don't use a 301 redirect, as browsers will cache the redirect and cause major problems. 302 is better. This is very important, as you can't get the general public to clear their browser cache once they've cached an incorrect redirect. It will just keep on redirecting them to the wrong place, potentially for months.
So start with something like:
^/success_stories_for_pets_sp_195/
and ensure it's working. Note that I haven't included a $ on the end, so URLs that start with that path will all get redirected.Then start trying to target the double quote. Perhaps firstly try:
^/success_stories_for_pets_sp_195/\"
and:^/success_stories_for_pets_sp_195/["]
and if those didn't work, you could try:^/success_stories_for_pets_sp_195/[^\s\w\-]
[^\s\w\-] matches a single character that's not a alphanumeric character or underscore (the \w), or a space (\s) or a dash character. ie it will target more than just a " character, but that might still provide a practical solution if it doesn't impact any other traffic.
I misread the question - reading question mark instead of quotation mark.. :( My suggestion would have been \" instead - since you already tried that I suggest you follow up with what Terry is suggesting.