Jump to content

Release: Redirects


apeisa

Recommended Posts

Here is a beta version for anyone who wants to test.

[updated Link Below]

Use an asterisk to specify a wildcard.

Example: /somepage/*

This will (should) catch everything under /somepage/

The main differences:

- Hook is now "addHookBefore"

- SQL has changed to allow searching for wildcard

- Alternate Domain config field under module settings.

  • Like 5
Link to comment
Share on other sites

Also, I find what you're wanting to do with your site quite interesting. I have a question: why would you want to maintain the URI structure for the legacy site, instead of performing permanent redirects? If it's something that many developers do, I'd be willing to include the functionality in the new module

This isn't something I've ever needed before, but in this case, I need to maintain an aging IIS/MSSQL/.NET infrastructure that has sites and applications that don't warrant the development time to rebuild. There is an assortment of reasons why it needs to live on. :D

Link to comment
Share on other sites

Hang tight on that version. I just realized that wasn't the most current. I copied an earlier version by mistake in my rush to get to lunch.

I'll be back in front of my computer in a bit and will post the correct version.

Link to comment
Share on other sites

This isn't something I've ever needed before, but in this case, I need to maintain an aging IIS/MSSQL/.NET infrastructure that has sites and applications that don't warrant the development time to rebuild. There is an assortment of reasons why it needs to live on. :D

I see - makes sense indeed :)

Link to comment
Share on other sites

Just a quick note. We did a lot more testing here over the past few days. Made a few tweaks to the SQL, and added a new config option for response codes that trigger the redirect to another domain. Defaults are 200 and 301.

I'll post the updated version when I get to the office tomorrow.

  • Like 1
Link to comment
Share on other sites

Hey Tom,

This sounds great!

Maybe it already does this, but just a quick suggestion - would it work to have the wildcard used in the destination path so that:

with your example /programs/* rule:

/programs/my-program/ would get redirected to /about/programs/my-program/

  • Like 1
Link to comment
Share on other sites

Hi Adrian,

I'll need to see how complex that would be. I don't have an immediate need, so not sure I can devote time to it at the moment.

EDIT: I bet what Mike Anthony is building would accommodate that. His looks to have a lot more features.

Link to comment
Share on other sites

Adrian, Tom -

Indeed, it will support that, quite fully. It would be a case of directing /programs/{program:segment} to /about/programs/{program}. :)

I'm sure it'll be ready by the time you need it, Adrian. I worked on a bit yesterday (importing). I have exporting on the to-do list, but I wonder how necessary it is. I may just leave it out, until someone needs it. Or perhaps we put it to a vote, or discuss further.

Anyways, by the end of next month, I'd like to have a beta put up. I know it sounds like a long way away, but I assure you, if I had time on my hands, this module would be finished by Friday next week, if not sooner.

Edit: I need to get everyone first names right! Hehe! :P

  • Like 2
Link to comment
Share on other sites

Hi Mike,

I originally had hardcoded the module to only redirect if the alt domain and URI returned a 200, but in my case the alternate domain has 13 years of vanity URI's that I don't want to migrate. So I figured it would be good to have it configurable. 200, 301, 302 are the ones I get back most.

Link to comment
Share on other sites

  • 3 weeks later...

I am not able to install the module ProcessRedirects on one of my domains. On two other domains ProcessRedirects is working perfectly, I am using the latest stable ProcessWire release 2.5.3 on all three domains.

After installation the ProcessRedirects module does not appear in the setup menu. When I try to uninstall it (before clean re-installation), I get an error message “This page may not be deleted”. Removing the module manually from the /site/modules/ directory did not help as well.

How to get the module working again?

I also already  removed the “processredirects” entry from the mySQL database.
Is there any other entries I have to remove from the database (in "modules" I did not find any)?

Thanks a lot for your help!
 

Link to comment
Share on other sites

You mean "Admin/Setup/Redirects" ? No, there is no such page. (I compared it with another processwire installation where ProcessRedirects is working no problem, on this installation the Redirects page is in place).

I tried to install and uninstall the module several times, it might be better to completely remove the module before re-installation?

Link to comment
Share on other sites

After turning debug mode on (config.php) and trying to uninstall ProcessRedirects there is this error message (I shortened the pathes with "......"):

 TemplateFile: This page may not be deleted<pre>#0 [internal function]: Pages->___delete(Object(NullPage)) #1 /homepages/......./wire/core/Wire.php(389): call_user_func_array(Array, Array) #2 /homepages/......./wire/core/Wire.php(344): Wire->runHooks('delete', Array) #3 /homepages/......./wire/core/Page.php(1193): Wire->__call('delete', Array) #4 /homepages/......./wire/core/Page.php(1193): Pages->delete(Object(NullPage)) #5 /homepages/......./site/modules/ProcessRedirects/ProcessRedirects.module(343): Page->delete() #6 [internal function]: ProcessRedirects->___uninstall() #7 /homepages/......./wire/core/Wire.php(389): call_user_func_array(Array, Array) #8 /homepages/......./wire/core/Wire.php(344): Wire->runHooks('uninstall', Array) #9 /homepages/......./wire/core/Modules.php(1368): Wire->__call('uninstall', Array) #10 /homepages/......./wire/core/Modules.php(1368): ProcessRedirects->uninstall() #11 [internal function]: Modules->___uninstall('ProcessRedirect...') #12 /homepages/......./wire/core/Wire.php(389): call_user_func_array(Array, Array) #13 /homepages/......./wire/core/Wire.php(344): Wire->runHooks('uninstall', Array) #14 /homepages/......./wire/modules/Process/ProcessModule/ProcessModule.module(1155): Wire->__call('uninstall', Array) #15 /homepages/......./wire/modules/Process/ProcessModule/ProcessModule.module(1155): Modules->uninstall('ProcessRedirect...') #16 /homepages/......./wire/modules/Process/ProcessModule/ProcessModule.module(1044): ProcessModule->renderEdit('ProcessRedirect...', Array) #17 [internal function]: ProcessModule->___executeEdit() #18 /homepages/......./wire/core/Wire.php(389): call_user_func_array(Array, Array) #19 /homepages/......./wire/core/Wire.php(344): Wire->runHooks('executeEdit', Array) #20 /homepages/......./wire/core/ProcessController.php(204): Wire->__call('executeEdit', Array) #21 /homepages/......./wire/core/ProcessController.php(204): ProcessModule->executeEdit() #22 [internal function]: ProcessController->___execute() #23 /homepages/......./wire/core/Wire.php(389): call_user_func_array(Array, Array) #24 /homepages/......./wire/core/Wire.php(344): Wire->runHooks('execute', Array) #25 /homepages/......./wire/core/admin.php(85): Wire->__call('execute', Array) #26 /homepages/......./wire/core/admin.php(85): ProcessController->execute() #27 /homepages/......./wire/modules/AdminTheme/AdminThemeDefault/controller.php(13): require('/homepages/30/d...') #28 /homepages/......./site/templates/admin.php(15): require('/homepages/30/d...') #29 /homepages/......./wire/core/TemplateFile.php(169): require('/homepages/30/d...') #30 [internal function]: TemplateFile->___render() #31 /homepages/......./wire/core/Wire.php(389): call_user_func_array(Array, Array) #32 /homepages/......./wire/core/Wire.php(344): Wire->runHooks('render', Array) #33 /homepages/......./wire/modules/PageRender.module(356): Wire->__call('render', Array) #34 /homepages/......./wire/modules/PageRender.module(356): TemplateFile->render() #35 [internal function]: PageRender->___renderPage(Object(HookEvent)) #36 /homepages/......./wire/core/Wire.php(389): call_user_func_array(Array, Array) #37 /homepages/......./wire/core/Wire.php(344): Wire->runHooks('renderPage', Array) #38 /homepages/......./wire/core/Wire.php(411): Wire->__call('renderPage', Array) #39 /homepages/......./wire/core/Wire.php(411): PageRender->renderPage(Object(HookEvent)) #40 /homepages/......./wire/core/Wire.php(344): Wire->runHooks('render', Array) #41 /homepages/......./wire/modules/Process/ProcessPageView.module(171): Wire->__call('render', Array) #42 /homepages/......./wire/modules/Process/ProcessPageView.module(171): Page->render() #43 [internal function]: ProcessPageView->___execute(true) #44 /homepages/......./wire/core/Wire.php(389): call_user_func_array(Array, Array) #45 /homepages/......./wire/core/Wire.php(344): Wire->runHooks('execute', Array) #46 /homepages/......./index.php(214): Wire->__call('execute', Array) #47 /homepages/......./index.php(214): ProcessPageView->execute(true) #48 {main}</pre>
 
 
After manually removing ProcessRedirects from the server and trying to uninstall it again:
 
Warning: class_implements(): Class ProcessRedirects does not exist and could not be loaded in /homepages/......./wire/modules/Process/ProcessModule/ProcessModule.module on line 1093

Warning: in_array() expects parameter 2 to be array, boolean given in /homepages/......./wire/modules/Process/ProcessModule/ProcessModule.module on line 1093

After this and when trying to install the module again there is no error message but there is also no ProcessRedirects installed:

Recently Found and Installed Modules:
Within the last day
No modules found.

Link to comment
Share on other sites

For some reason the install routine has failed to create the page, and uninstall fails to delete the page that doesn't exists.

Not sure why it fails in first place, but there are probably lot that can be tweaked at the install routine (code is little old already).

Link to comment
Share on other sites

  • 2 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...