Help with smart redirect rule
-
Hi
I’m doing a site around an event plugin. The cpt this plugin creates has an ordinary link structure to its category pages like so:
https://gbv.sinkadus.com/event_cat/permakultur/
My question is of its possible to setup a redirect rule that would automatically create a redirect to all those category links so this:
https://gbv.sinkadus.com/event_cat/permakultur/
Would lead to:
https://gbv.sinkadus.com/permakultur/
I tried this:
/event_cat/permakultur/.+. –> /permakultur/
And:
/event_cat/permakultur/(.+) —> /permakultur/
But it didn’t work. Am I close? Or is it not possible to achieve what I want with this plugin?
Thankful for any help ??
The page I need help with: [log in to see the link]
-
It seems like what you did should work as regular expression redirect.
You could turn on debug logging, but if it’s not matching the regular expression then it won’t show up in the log.
To turn on debug logging you can go to 404 Solution -> Options -> Advanced Settings (Etc) -> Debug logging (and check the box). (Or just search for “Debug logging” on the options page.) Then you can click “View the debug log” after you test the regular expression.
Note that the destination for the redirect can’t be “/permakultur/”. You have to either choose a page/category from the dropdown list, or type in a fully qualified URL like https://gbv.sinkadus.com/permakultur/.
Also note that you’ve used .+ which means there must be at least one character after the /event_cat/permakultur/ part, so “/event_cat/permakultur/” exactly will not redirect (but /event_cat/permakultur/a or /event_cat/permakultur/abc will). If you want it to match 0 or more characters then you would use /event_cat/permakultur/.* or perhaps /event_cat/permakultur.*
Thanks for quick reply!
Weird… hmm. Yes, I have chosen the page “konstplattform”, so that was/is correct.
I did turn on debugging, but there is nothing in the log that makes sense to me. Is there something here:
Contents of: /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/uploads/temp_abj404_solution/abj404_debug.txt: 2022-06-22 20:25:48 GMT+0000 (INFO): 62b37acbb00651.55934538: Updating database version from 0.0.0 to 2.30.15 (begin). 2022-06-22 20:25:48 GMT+0000 (ERROR): Ugh. SQL query error: Table 'sinkadus_gbv.wp_abj404_lookup' doesn't exist, SQL: /* ------------------ /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/sql/correctLookupTableIssue.sql BEGIN ----- */ delete from wp_abj404_lookup where lkup_value in ( select * from ( SELECT DISTINCT lkup_value FROM wp_abj404_lookup group by lkup_value having count(lkup_value) > 1 ) a ) /* ------------------ /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/sql/correctLookupTableIssue.sql END ----- */ , Execution time: 0, DB ver: 10.4.25, Variables: Array ( [0] => Array ( [max_join_size] => 18446744073709551615 [sql_big_selects] => 1 ) ) , PHP version: 7.4.29, WP ver: 5.9.3, Plugin ver: 2.30.15, Referrer: https://gbv.sinkadus.com/wp-admin/plugin-install.php?s=404%20solution&tab=search&type=term, Requested URL: /wp-admin/plugins.php?_wpnonce=643756303b&action=activate&plugin=404-solution%2F404-solution.php, Stored debug messages: , Trace: #0 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/DataAccess.php(227): ABJ_404_Solution_Logging->errorMessage('Ugh. SQL query ...') #1 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/DataAccess.php(434): ABJ_404_Solution_DataAccess->queryAndGetResults('\n/* -----------...') #2 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/DatabaseUpgradesEtc.php(75): ABJ_404_Solution_DataAccess->correctDuplicateLookupValues() #3 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/DatabaseUpgradesEtc.php(51): ABJ_404_Solution_DatabaseUpgradesEtc->correctIssuesBefore() #4 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/DatabaseUpgradesEtc.php(41): ABJ_404_Solution_DatabaseUpgradesEtc->reallyCreateDatabaseTables(true) #5 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/PluginLogic.php(375): ABJ_404_Solution_DatabaseUpgradesEtc->createDatabaseTables(true) #6 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/PluginLogic.php(335): ABJ_404_Solution_PluginLogic->updateToNewVersionAction(Array) #7 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/PluginLogic.php(305): ABJ_404_Solution_PluginLogic->updateToNewVersion(Array) #8 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/SpellChecker.php(27): ABJ_404_Solution_PluginLogic->getOptions() #9 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/SpellChecker.php(43): ABJ_404_Solution_SpellChecker::getInstance() #10 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/Loader.php(51): ABJ_404_Solution_SpellChecker::init() #11 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/404-solution.php(76): require_once('/home/sinkadus/...') #12 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-admin/includes/plugin.php(2288): include_once('/home/sinkadus/...') #13 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-admin/includes/plugin.php(659): plugin_sandbox_scrape('404-solution/40...') #14 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-admin/plugins.php(58): activate_plugin('404-solution/40...', 'https://gbv.sin...', false) #15 {main} 2022-06-22 20:25:48 GMT+0000 (ERROR): Ugh. SQL query error: Table 'sinkadus_gbv.wp_abj404_spelling_cache' doesn't exist, SQL: delete from wp_abj404_spelling_cache where matchdata is null or matchdata = '', Execution time: 0, DB ver: 10.4.25, Variables: Array ( [0] => Array ( [max_join_size] => 18446744073709551615 [sql_big_selects] => 1 ) ) , PHP version: 7.4.29, WP ver: 5.9.3, Plugin ver: 2.30.15, Referrer: https://gbv.sinkadus.com/wp-admin/plugin-install.php?s=404%20solution&tab=search&type=term, Requested URL: /wp-admin/plugins.php?_wpnonce=643756303b&action=activate&plugin=404-solution%2F404-solution.php, Stored debug messages: , Trace: #0 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/DataAccess.php(227): ABJ_404_Solution_Logging->errorMessage('Ugh. SQL query ...') #1 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/DatabaseUpgradesEtc.php(88): ABJ_404_Solution_DataAccess->queryAndGetResults('delete from wp_...') #2 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/DatabaseUpgradesEtc.php(77): ABJ_404_Solution_DatabaseUpgradesEtc->correctMatchData() #3 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/DatabaseUpgradesEtc.php(51): ABJ_404_Solution_DatabaseUpgradesEtc->correctIssuesBefore() #4 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/DatabaseUpgradesEtc.php(41): ABJ_404_Solution_DatabaseUpgradesEtc->reallyCreateDatabaseTables(true) #5 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/PluginLogic.php(375): ABJ_404_Solution_DatabaseUpgradesEtc->createDatabaseTables(true) #6 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/PluginLogic.php(335): ABJ_404_Solution_PluginLogic->updateToNewVersionAction(Array) #7 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/PluginLogic.php(305): ABJ_404_Solution_PluginLogic->updateToNewVersion(Array) #8 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/SpellChecker.php(27): ABJ_404_Solution_PluginLogic->getOptions() #9 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/SpellChecker.php(43): ABJ_404_Solution_SpellChecker::getInstance() #10 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/includes/Loader.php(51): ABJ_404_Solution_SpellChecker::init() #11 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/plugins/404-solution/404-solution.php(76): require_once('/home/sinkadus/...') #12 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-admin/includes/plugin.php(2288): include_once('/home/sinkadus/...') #13 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-admin/includes/plugin.php(659): plugin_sandbox_scrape('404-solution/40...') #14 /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-admin/plugins.php(58): activate_plugin('404-solution/40...', 'https://gbv.sin...', false) #15 {main} 2022-06-22 20:25:48 GMT+0000 (INFO): Updating collation from latin1_swedish_ci to utf8mb4_unicode_520_ci 2022-06-22 20:25:48 GMT+0000 (INFO): I succesfully changed the collation of wp_abj404_redirects to utf8mb4_unicode_520_ci 2022-06-22 20:25:48 GMT+0000 (INFO): I succesfully changed the collation of wp_abj404_logsv2 to utf8mb4_unicode_520_ci 2022-06-22 20:25:48 GMT+0000 (INFO): I succesfully changed the collation of wp_abj404_lookup to utf8mb4_unicode_520_ci 2022-06-22 20:25:48 GMT+0000 (INFO): I succesfully changed the collation of wp_abj404_permalink_cache to utf8mb4_unicode_520_ci 2022-06-22 20:25:48 GMT+0000 (INFO): I succesfully changed the collation of wp_abj404_spelling_cache to utf8mb4_unicode_520_ci 2022-06-22 20:25:48 GMT+0000 (INFO): 62b37acbb00651.55934538: Updating database version to 2.30.15 (end). 2022-06-22 20:25:48 GMT+0000 (INFO): 62b37acc0bd7b3.82600954: On wp_abj404_permalink_cache I'm updating various columns because we want:
Array
(
[0] =>id
bigint not null
[1] =>url
varchar(2048) not null
[2] =>meta
tinytext not null
[3] =>url_length
smallint default null
)but we have:
Array
(
[0] =>id
bigint not null
[1] =>url
varchar(2048) not null
[2] =>meta
text not null
[3] =>url_length
smallint default null
)2022-06-22 20:25:48 GMT+0000 (INFO): I updated a column: alter table wp_abj404_permalink_cache change meta
meta
tinytext not null
2022-06-22 20:25:48 GMT+0000 (INFO): No more differences found after updating the wp_abj404_permalink_cache table columns. All is well.
2022-06-22 20:25:48 GMT+0000 (INFO): 62b37acc0bd7b3.82600954: On wp_abj404_spelling_cache I’m updating various columns because we want:Array ( [0] => <code>id</code> bigint not null auto_increment [1] => <code>url</code> varchar(2048) not null [2] => <code>matchdata</code> text not null ) but we have: Array ( [0] => <code>id</code> bigint not null auto_increment [1] => <code>url</code> varchar(2048) not null [2] => <code>matchdata</code> mediumtext not null ) 2022-06-22 20:25:48 GMT+0000 (INFO): I updated a column: alter table wp_abj404_spelling_cache change matchdata <code>matchdata</code> text not null 2022-06-22 20:25:48 GMT+0000 (INFO): No more differences found after updating the wp_abj404_spelling_cache table columns. All is well. 2022-06-22 20:25:50 GMT+0000 (INFO): deleteOldRedirectsCron. Old captured URLs removed: 0, Old automatic redirects removed: 0, Old manual redirects removed: 0, Old log lines removed: 0, New log size: 0MB, Duplicate rows deleted: 0, Debug file size limited: false, Admin email notification option turned off., Permlink cache rows updated: 0, User initiated: false 2022-06-23 04:16:13 GMT+0000 (INFO): deleteOldRedirectsCron. Old captured URLs removed: 0, Old automatic redirects removed: 0, Old manual redirects removed: 0, Old log lines removed: 0, New log size: 0MB, Duplicate rows deleted: 0, Debug file size limited: false, Admin email notification option turned off., Permlink cache rows updated: 0, User initiated: false 2022-06-23 12:41:12 GMT+0000 (DEBUG): Processing request for action: (none) 2022-06-23 12:41:12 GMT+0000 (DEBUG): Displaying sub page: abj404_options 2022-06-23 12:42:06 GMT+0000 (DEBUG): Processing request for action: (none) 2022-06-23 12:42:06 GMT+0000 (DEBUG): Displaying sub page: abj404_options 2022-06-23 12:42:17 GMT+0000 (DEBUG): Processing request for action: (none) 2022-06-23 12:42:17 GMT+0000 (DEBUG): Displaying sub page: abj404_logs 2022-06-23 12:42:17 GMT+0000 (DEBUG): 1 log records displayed on the page. 2022-06-23 12:42:26 GMT+0000 (DEBUG): Processing request for action: (none) 2022-06-23 12:42:26 GMT+0000 (DEBUG): Displaying sub page: abj404_options 2022-06-23 12:42:34 GMT+0000 (DEBUG): Processing request for action: (none) 2022-06-23 12:42:34 GMT+0000 (DEBUG): Displaying sub page: abj404_debugfile 2022-06-23 12:43:47 GMT+0000 (DEBUG): Processing request for action: (none) 2022-06-23 12:43:47 GMT+0000 (DEBUG): Displaying sub page: abj404_redirects 2022-06-23 12:43:47 GMT+0000 (DEBUG): Found 1 rows to display before log data and 1 rows to display after log data for page: abj404_redirects 2022-06-23 12:43:55 GMT+0000 (DEBUG): Processing request for action: (none) 2022-06-23 12:43:55 GMT+0000 (DEBUG): Displaying sub page: abj404_edit 2022-06-23 12:43:55 GMT+0000 (DEBUG): Edit redirect page. GET ID: "1" 2022-06-23 12:44:07 GMT+0000 (DEBUG): Processing request for action: editRedirect 2022-06-23 12:44:07 GMT+0000 (DEBUG): Displaying sub page: abj404_redirects 2022-06-23 12:44:07 GMT+0000 (DEBUG): Found 1 rows to display before log data and 1 rows to display after log data for page: abj404_redirects 2022-06-23 12:44:39 GMT+0000 (DEBUG): Processing request for action: (none) 2022-06-23 12:44:39 GMT+0000 (DEBUG): Displaying sub page: abj404_edit 2022-06-23 12:44:39 GMT+0000 (DEBUG): Edit redirect page. GET ID: "1" 2022-06-23 12:44:44 GMT+0000 (DEBUG): Processing request for action: editRedirect 2022-06-23 12:44:44 GMT+0000 (DEBUG): Displaying sub page: abj404_redirects 2022-06-23 12:44:44 GMT+0000 (DEBUG): Found 1 rows to display before log data and 1 rows to display after log data for page: abj404_redirects 2022-06-23 12:46:30 GMT+0000 (DEBUG): Processing request for action: (none) 2022-06-23 12:46:30 GMT+0000 (DEBUG): Displaying sub page: abj404_debugfile Contents of: /home/sinkadus/domains/gbv.sinkadus.com/public_html/wp-content/uploads/temp_abj404_solution/abj404_debug.txt_old.txt: (The log file does not exist.)
My redirect:
The most recent lines of the debug file will show the most recent requests. For example:
`2022-06-23 12:28:54 GMT+0000 (DEBUG): Processing 404 for URL: /404solution-site/example/ssss | Redirect: {“id”:0} | is_single(): | is_page(): | is_feed(): | is_trackback(): | is_preview(): | options: auto_redirects: 1, auto_score: 90, auto_cats: 1, auto_tags: 1, dest404page: 13689|1, HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36, REMOTE_ADDR: ::64p913h85p40, REQUEST_URI: /404solution-site/example/ssss
2022-06-23 12:28:54 GMT+0000 (DEBUG): No posts or pages matching slug: ssss
2022-06-23 12:28:54 GMT+0000 (DEBUG): Logging redirect. Referer: | Current user: aaron | From: /404solution-site/example/ssss to: https://localhost:8888/404solution-site/category/behavior/, Reason: regex match, Ignore msg(s): , Execution time: 0.15 seconds, permalinks found: (not set)`If you don’t see a “Processing 404 for URL” then the plugin wasn’t triggered. One of the things I forgot to note was that if there’s no 404 then the redirect won’t happen because the plugin only tries to redirect when there’s a 404. If the page exists then there’s no 404…
Ah… and there is no way to force a redirect without 404 being triggered?
The redirect in the image you’ve shown, from https://gbv.sinkadus.com/event_cat/konstplattform/abcd to https://gbv.sinkadus.com/konstplattform/ seems to be working fine.
There is no way for force a redirect without a 404 using this plugin. You could use .htaccess or you could delete or rename the page so that the URL causes a 404.
Hmm in what browser? I have tried in Brave, Opera, Safari, Chrome and Firefox (on Mac). Doesn’t work.
And just for clarity: its this link:
Update: solved it with this plugin.
Lots of thanks for quick reply and good info ??
- The topic ‘Help with smart redirect rule’ is closed to new replies.