Closed hiousi closed 6 years ago
Huh... I tested with quite a few different variations before tagging this... Would it be possible for you to try with it installed in the root? Or if the intermediate path segments (Default/Pages
) were lowercased?
(if either are the issue I hope to fix them, of course, just trying to get some idea of where the issue is)
@SahAssar I've just finished to move to root and lowercased.
http://mydomain.com/default/pages/about_us.aspx
is redirected to
http://mydomain.com/default/pages/pages/about-us
I'm using Bolt 3.1
Sorry, yes this is definitely an issue... The trimming makes the redirect relative, not absolute. I'll patch it and tag a release in a few mins.
@SahAssar great! it now works with bolt on / but not in a subfolder
http://mydomain.com/subfolder/Default/Pages/About_Us.aspx
is redirected to
http://mydomain.com/pages/about-us
The workaround I found is changing the config to:
redirects:
aboutus:
from: 'Default/Pages/About_Us.aspx'
to: 'subfolder/pages/about-us'
I'm not sure it is the intended way to make it work.
If I'm not mistaken, my original intention was for it to work from a subfolder, but honestly can't remember. I think the idea here is to actually form a full URL: <site root>/<redirect path>
Hmm... I'm not that used to working with sites not on the root, but I think I could make this work by adding a check for that. The issue would be that users might expect them to be absolute, as in that they could redirect to non-site-root locations, so accounting for that might take some additional thought.
Perhaps then it could default to generating an absolute URL unless it is prefixed with a slash which would indicate from the domain root. In other words, only prepend the site root if the destination is not prefixed by a slash. This could perhaps also account for ../
Well, embedding configuration in the path seems like what led to at least my confusion on this issue to start with... Personally I'd prefer to have something like this:
redirects:
aboutus:
from: 'Default/Pages/About_Us.aspx'
to: 'pages/about-us'
absolute: true
if one want's absolute redirects, and having the default be relative to the site root. Also having a global absolute_paths: true
would probably make this workable for most use-cases, no?
That could also work, yes.
can the original path be removed and re-added to the redirect?
I mean, with the config above, with an url like:
http://thedomain.com/sub1/sub1/Default/Pages/About_Us.aspx
, isolate /sub1/sub1/
and prefix it to the "to:" param and finaly redirect to /sub1/sub1/pages/about-us
http://thedomain.com/Default/Pages/About_Us.aspx
, isolate /
and prefix it to finaly redirect to /pages/about-us
@hiousi That might work... Actually I can't think of a reason right now why it wouldn't (unless one wants to redirect from a folder to the root or another subfolder).
@sahAssar in the case you want to redirect up one or more path to root, as suggested @mikerockett somthing like to: ../../pages/about-us
and finaly to go to root of the domain to: /pages/about-use
sure, it will need some more code to parse the parameters and compile it to a good url
AFIK there is no way to have both portable and non-root redirects at the same time. I could work around it with configs (I had written a whole thing about adding a base
param with the options bolt
and root
) but that would probably not be better than what we have now.
The way it works now is that all redirects are absolute, so they will work in a subfolder, but only if prefixed with that subfolders name. In other words: when I redirect I write the path I want to redirect to.
How about I remove the trimming of slashes to make this explicit and update the docs to reflect this? That way it would be the simple request url -> redirect url, without the extension caring about subfolders or anything else and it'd be predictable.
Of course I'd tag a new major version for this since it'd be incompatible with the previous configs.
Hi,
I tried adding a redirect, I added an absolute path to the "to" config but it is not redirecting to the actual value. Instead, the "to" value was appended in the current path.
redirects:
test:
from: 'test'
to: 'http://www.otherpath.com/test'
it will redirect to, http://www.currentpath.com/http://www.otherpath.com/test
Am I missing some configurations?
Thanks!
@edanao Hi, sorry for the late reply, but IIRC there is no way to redirect to other domains with this currently. The discussion here was about absolute paths (as in always relative to the domain root, not the current path), not about full URI's. If redirecting to another domain I usually use the server config, but I'll definetly consider your use case in a future version.
@SahAssar You should probably update the docs then, as this was originally supported.
This works in my installation? Full URL redirect;)
Fixed in #19 :)
Hi there,
With my server configuration documentation first example does not work
http://mydomain.com/folder/Default/Pages/About_Us.aspx
is redirected tohttp://mydomain.com/folder/Default/Pages/pages/about-us
Please note that bolt is installed in a subfolder
/folder
Did I did something wrong?