July 21, 2016 at 10:02 am - Views: 39 #3929
GoutPal HelpDeskParticipantŦallars: Ŧ 53.90
When I check my Redirection 404 logs, I get lots of errors for square.png. It’s always at the end of a URL. i.e. /valid-page/square.png.
I’ve searched Google for explanations, but I cannot find anything that explains why these requests are generated. There are hints that it might be something related to Apple browsers, but nothing conclusive. In the absence of anything else, I’d like to redirect these 404s to my favicon.
I’m familiar with adding wildcards for URL endings using Redirection’s regex feature. I use a /partial-url(.*) and tick the regex box.
Can anyone tell me the regex for square.png at the end of a URL?
Attachments:You must be logged in to view attached files.
July 21, 2016 at 10:32 am #3934
AnnaKeymasterŦallars: Ŧ 47.55
I googled “redirection regex” for more information about wildcard settings for the WordPress Redirection Plugin. Unfortunately, the official documentation has not been updated as the plugin has evolved. Therefore, it is a little confusing.
The author writes:
Regular expressions are a complicated subject and this page will not attempt to give more than a passing overview of using them. If you do need more help then you should take a look at a regular expression website.
That’s fair enough for a free WordPress plugin. But, I feel a few well chosen, practical, examples will make the plugin easier to use. Let’s not get sidetracked on potential projects for improving Redirection.
Just before my quoted section, we see “the (.*) a sequence of characters”. In your example, (.*) indicates any sequence of characters at the end of a URL. What you are really looking for is a regular expression (regex) for any sequence of characters at the beginning of a URL. So, you need
(.*)square.pngin your Redirection Source URL.
I’ve tested this 404 redirect using the settings from the screenshot. It works, but might cause problems if you ever want to use an image on your website titled square.png.
You should Connect to Shrewdies to reply to this topic.
Simply click one of the buttons above to connect using your favourite network. Then, a box will appear here for you to post your reply.