Custom 404 Page by Siropu

Custom 404 Page by Siropu 1.1.7

No permission to download
Assuming that /wp/ is not a valid route for you, try something like this in this addon...
Regex: /(.*)\/wp\/(.*)/
Replancement: $1

Be sure to test it of course but the end result should be any attempts at going to http://example.com/wp/{anything} should get redirected automatically to http://example.com instead.


EDIT: If you have the .htaccess change in place you shouldn't be seeing 404's for "http://example.com".
Ok thanks, I'll try that regex and see how it goes. You're right about the htaccess - I made changes and for some reason I didn't add the http to https redirect. I'll add it back in and see.

Most likely this is a bot probing for vulnerabilities. If you use cloudflare then set up a page rule to ban any IP that hits this URL.
I think it is a bot. I don't use cloudflare though.
 
I would not use a redirect for this case. Its a malicious bot that needs to be blocked. Not redirected to a working page. See if you can get some server side protection against probing. Ask your host. Or get the IP address and user agent from the log and block those. Or use @DragonByte Tech 's Security addon to block it.
 
Go to src/addons/Siropu/Custom404Page/Admin/Controller/NotFound.php and replace:

PHP:
$finder->whereOr([['url', $filter['url']], ['redirect_url', $filter['url']]]);
With:
PHP:
if (strpos($filter['url'], '*') !== false)
     {
          $escapeLike = $finder->escapeLike(str_replace('*', '', $filter['url']), '%?%');
          $finder->whereOr([['url', 'LIKE', $escapeLike], ['redirect_url', 'LIKE', $escapeLike]]);
     }
     else
     {
          $finder->whereOr([['url', $filter['url']], ['redirect_url', $filter['url']]]);
     }

Let me know how that works for you. It will be included in the next release.
 
When uploaded files:
Server error log
  • XF\Db\Exception: MySQL statement prepare error [1054]: Unknown column 'ip' in 'field list'
  • src/XF/Db/AbstractStatement.php:217
  • Generated by: Unknown account
  • Jun 4, 2019 at 6:37 PM
Stack trace
INSERT INTO xf_siropu_custom_404_page_not_found (url, entry_date, last_view_date, redirect_url, referrer, ip, view_count) VALUES (?, ?, ?, ?, ?, ?, ?)
------------

#0 src/XF/Db/Mysqli/Statement.php(196): XF\Db\AbstractStatement->getException('MySQL statement...', 1054, '42S22')
#1 src/XF/Db/Mysqli/Statement.php(39): XF\Db\Mysqli\Statement->getException('MySQL statement...', 1054, '42S22')
#2 src/XF/Db/Mysqli/Statement.php(54): XF\Db\Mysqli\Statement->prepare()
#3 src/XF/Db/AbstractAdapter.php(94): XF\Db\Mysqli\Statement->execute()
#4 src/XF/Db/AbstractAdapter.php(218): XF\Db\AbstractAdapter->query('INSERT INTO `x...', Array)
#5 src/XF/Mvc/Entity/Entity.php(1452): XF\Db\AbstractAdapter->insert('xf_siropu_custo...', Array, false)
#6 src/XF/Mvc/Entity/Entity.php(1184): XF\Mvc\Entity\Entity->_saveToSource()
#7 src/addons/Siropu/Custom404Page/Listener.php(59): XF\Mvc\Entity\Entity->save()
#8 [internal function]: Siropu\Custom404Page\Listener::appPubComplete(Object(XF\Pub\App), Object(XF\Http\Response))
#9 src/XF/Extension.php(67): call_user_func_array(Array, Array)
#10 src/XF/App.php(2647): XF\Extension->fire('app_pub_complet...', Array, NULL)
#11 src/XF/Pub/App.php(462): XF\App->fire('app_pub_complet...', Array)
#12 src/XF/App.php(2180): XF\Pub\App->complete(Object(XF\Http\Response))
#13 src/XF.php(390): XF\App->run()
#14 index.php(20): XF::runApp('XF\\Pub\\App')
#15 {main}
Request state
array(4) {
["url"] => string(11) "/search/45/"
["referrer"] => bool(false)
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}
 
Go to src/addons/Siropu/Custom404Page/Admin/Controller/NotFound.php and replace:

PHP:
$finder->whereOr([['url', $filter['url']], ['redirect_url', $filter['url']]]);
With:
PHP:
if (strpos($filter['url'], '*') !== false)
     {
          $escapeLike = $finder->escapeLike(str_replace('*', '', $filter['url']), '%?%');
          $finder->whereOr([['url', 'LIKE', $escapeLike], ['redirect_url', 'LIKE', $escapeLike]]);
     }
     else
     {
          $finder->whereOr([['url', $filter['url']], ['redirect_url', $filter['url']]]);
     }

Let me know how that works for you. It will be included in the next release.

Thanks, I'll give that a shot this afternoon :)
 
What is this shown at the bottom?
HTML:
<pre class="sf-dump" id="sf-dump-1723588720" data-indent-pad="  "><span class="sf-dump-num">1</span>
</pre>
 
It seems that a test code ended up in the template: {{ dump(1) }}
Go to admin options and hit save to update the template.
 
  • Like
Reactions: rdn
I get stuff like http://example.com/wp/wp-admin/index.php which doesn't exist, but I'm seeing it often.

I'm also getting these - obviously a bot crawling for Wordpress vulnerabilities.
Most likely this is a bot probing for vulnerabilities.
Indeed, on my Wordpress site I also get bots looking for plugins that I don't have and never did - same thing.
Its a malicious bot that needs to be blocked. Not redirected to a working page.

Good idea
 
I'm getting a few of these:

Code:
https://cafesaxophone.com/apple-touch-icon-precomposed.png

Anyone know if I should redirect or just create that icon?
 
We were getting a lot of these errors when we had a missing Favicon (forum URL edited in the dump). Once we replaced the missing icon, the error stopped. But we wanted you to know it was happening.

XF\Db\Exception: MySQL query error [1406]: Data too long for column 'referrer' at row 1​
src/XF/Db/AbstractStatement.php:217​
UPDATE xf_siropu_custom_404_page_not_found SET last_view_date = ?, view_count = ?, referrer = ?, ip = ? WHERE entry_id = 1​
------------​
#0 src/XF/Db/Mysqli/Statement.php(196): XF\Db\AbstractStatement->getException('MySQL query err...', 1406, '22001')​
#1 src/XF/Db/Mysqli/Statement.php(77): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1406, '22001')​
#2 src/XF/Db/AbstractAdapter.php(94): XF\Db\Mysqli\Statement->execute()​
#3 src/XF/Db/AbstractAdapter.php(326): XF\Db\AbstractAdapter->query('UPDATE `xf_sir...', Array)​
#4 src/XF/Mvc/Entity/Entity.php(1457): XF\Db\AbstractAdapter->update('xf_siropu_custo...', Array, 'entry_id = 1')​
#5 src/XF/Mvc/Entity/Entity.php(1184): XF\Mvc\Entity\Entity->_saveToSource()​
#6 src/addons/Siropu/Custom404Page/Listener.php(47): XF\Mvc\Entity\Entity->save()​
#7 [internal function]: Siropu\Custom404Page\Listener::appPubComplete(Object(XF\Pub\App), Object(XF\Http\Response))​
#8 src/XF/Extension.php(67): call_user_func_array(Array, Array)​
#9 src/XF/App.php(2647): XF\Extension->fire('app_pub_complet...', Array, NULL)​
#10 src/XF/Pub/App.php(462): XF\App->fire('app_pub_complet...', Array)​
#11 src/XF/App.php(2180): XF\Pub\App->complete(Object(XF\Http\Response))​
#12 src/XF.php(390): XF\App->run()​
#13 index.php(20): XF::runApp('XF\\Pub\\App')​
#14 {main}​
Request state​
array(4) {​
["url"] => string(30) "/community/favicon-128x128.png"​
["_GET"] => array(0) {​
}​
["_POST"] => array(0) {​
}​
}​
 
We are very happy with the functionality of the add-on, though it's quite a Sisyphus task to set up all redirects.

I was wondering if someone could help us with a bit of RegEx. We are getting hundreds of requests like this:

https://mysite.com/forums/forum-name-123/thread-title-45678

and would like to redirect them to

https://mysite.com/threads/thread-title.45678/.

Also, how can we exclude / ignore malformatted URLs that end in particular appended strings, such as

/view
/open
-print/ etc. ?

Thanks for any pointers.
 
You may want to do a database replacement query for that as well:
Code:
UPDATE xf_post SET message = REPLACE(message, 'https://mysite.com/forums/forum-name-123/thread-title-', 'https://mysite.com/threads/thread-title.');
 
Top Bottom