Erbenos Posted September 27, 2016 Share Posted September 27, 2016 (edited) Hello, I encountered interesting behaviour yesterday. I have custom module, which serves as 404 redirect which works like this: $this->addHookAfter("ProcessPageView::pageNotFound", $this, "hook404Page"); And in hook404Page function I return 404 page. The problem is while this does work for: http://testsite.dev/nonpage It doesn't work for non standard URL like these: http://testsite.dev/něnpage Any idea why? Thanks. Edited September 27, 2016 by Erbenos English is hard Link to comment Share on other sites More sharing options...
Mike Rockett Posted September 28, 2016 Share Posted September 28, 2016 You need to enable UTF8 URIs in your htaccess file. I assume you are using ProcessWire 2.8 or 3.0, and so you can simply comment out rule 16a and uncomment rule 16b (if I'm not mistaken). This should enable the URIs you would like to use. 1 Link to comment Share on other sites More sharing options...
Erbenos Posted September 29, 2016 Author Share Posted September 29, 2016 Thank you, but that didn't fix it for me. I chanched htaccess, restarted Apache and nothing changed. Link to comment Share on other sites More sharing options...
Mike Rockett Posted September 30, 2016 Share Posted September 30, 2016 7 hours ago, Erbenos said: Thank you, but that didn't fix it for me. I chanched htaccess, restarted Apache and nothing changed. Just to confirm did you uncomment this rule? RewriteCond %{REQUEST_URI} "^/~?[-_./a-zA-Z0-9æåäßöüđжхцчшщюяàáâèéëêěìíïîõòóôøùúûůñçčćďĺľńňŕřšťýžабвгдеёзийклмнопрстуфыэęąśłżź]*$" Also, you don't need to restart Apache when changing htaccess files; you only need to restart if you have changed a configuration file, such as httpd.conf or a virtual host file. 1 Link to comment Share on other sites More sharing options...
Erbenos Posted September 30, 2016 Author Share Posted September 30, 2016 Yes, that exact line: Link to comment Share on other sites More sharing options...
Mike Rockett Posted September 30, 2016 Share Posted September 30, 2016 Then I'm afraid I'm not sure what the problem is. I use the same hook and rul 16b for Jumplinks 2, and it works. Is your specific problem that your hook404Page method doesn't get triggered at all? Link to comment Share on other sites More sharing options...
BitPoet Posted September 30, 2016 Share Posted September 30, 2016 Could it be that the .htaccess file got convert to an ISO encoding? Link to comment Share on other sites More sharing options...
Erbenos Posted October 2, 2016 Author Share Posted October 2, 2016 I actually use your jumplinks plugin for redirecting old rules to the new ones. As @BitPoet said, I ll check encoding and will come back with an answer. Thanks everyone. Update: File is in UTF-8 Link to comment Share on other sites More sharing options...
Erbenos Posted October 2, 2016 Author Share Posted October 2, 2016 Whoa... this is kind of funny. There is setting specifically for what I want just below: # ----------------------------------------------------------------------------------------------- # 14. OPTIONAL: Send URLs with non-ASCII name-format characters to 404 page (optimization) # ----------------------------------------------------------------------------------------------- RewriteCond %{REQUEST_URI} "[^-_.a-zA-Z0-9/~]" RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?it=/http404/ [L,QSA] One may wonder how does he have utf8 page names and correct 404 redirects but oh well, this is just what i needed. Link to comment Share on other sites More sharing options...
Mike Rockett Posted October 3, 2016 Share Posted October 3, 2016 Surely that will automatically send anything that does not have -_.a-zA-Z0-9/~ to http404? Link to comment Share on other sites More sharing options...
Erbenos Posted October 3, 2016 Author Share Posted October 3, 2016 Yep, but I dont actually use utf-8 addresses, I just needed to redirect them to 404, because without this option, it wasn't working. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now