ivinteractive / kirbycms-redirects

GNU General Public License v3.0
33 stars 3 forks source link

intercepting urls question #1

Closed onezerodigits closed 8 years ago

onezerodigits commented 8 years ago

I've installed the plugin files/page/template/blueprint and function(). The rest of the site works fine, but the redirection I've added (inventory.html -> inventory) doesn't seem to be triggered.

I'm running this on a local php server, and I'm getting a standard php "The requested resource /inventory.html was not found on this server."

I suspect this problem is from my setup somewhere, so I'm curious if you have any suggestions to help? Thanks for any time you can spare.

ivi-admin commented 8 years ago

We tried this out on a local environment and were getting the same error -- seems to have been an issue with stripping the base path when the site is located in a subfolder. If you update to the latest commit and add c::set('redirecty-subfolder',true) to your config file, it should start working. Let us know!

onezerodigits commented 8 years ago

@ivinteractive unfortunately this didn't help my issue. If it's relevant, my site isn't in a subfolder. I don't have the chops to figure out what's wrong, but I'm happy to supply any info that might help debug. Here's the site repo I'm working on: https://github.com/nsteiner/city-issue I'm running PHP locally via NPM run script which you can see in the package.son file at the root - so in other words, if you have nodes installed, you can try this repo out if it helps. Install once with npm install then npm run dev to start up the local hosting.

I'm sharing this in case it's helpful, but if there's something else I can do or provide, please let me know! Thanks and cheers.

ivi-admin commented 8 years ago

Thanks, this was helpful -- the issue seems to lie with the URL rewriting. Since you're using PHP's built-in server it doesn't use the .htaccess, and it's not using Kirby's index.php when you request something that has a file extension. A redirect without a file extension worked for me (test1 => test).

It seems that you would have to essentially translate the .htaccess rules to PHP, something like this. Once you create a routing.php file, you'd just have to edit this line in your package.json:

"serve": "php -S localhost:8008 routing.php"

I tried the rule in the example I linked to above, which instead just returned a 500 error for inventory.html, so a working version would have to be more complex. Kirby's system requirements list PHP's built-in server as working. I wasn't able to find any examples of how the routing should work in the Kirby forum, but maybe you can ask there?

onezerodigits commented 8 years ago

Wonderful - this makes sense. If I find anything useful for this particular use case, I'll report back. Thanks again for all the help!