URL Router
This is an open discussion with 156 replies, filed under Extensions.
Search
Can I use this to route a url like so?
From: http://domain.com/about/ To: http://domain.com/?_escaped_fragment_=/about/
I want these two url return the same result. someone help?
Any Regex gurus around to assist in this query?
I'm looking to grab a url like this:
rootpage/first/second/third/fourth and map it to a url param like this: rootpage/first-second-third-fourth
Is this even possible? So in URL routet I'm after:
FROM: rootpage/first/second/third/fourth TO: rootpage/first-second-third-fourth
Or will Symphony throw a wobbly here?
Also the string may have any number of forward slashes it may need to replace with '-'s
That's not something that can be done with the URL Router, or even vanilla regex I'm afraid. It requires a preg_split
and then implode
in PHP.
I've already been down the route your looking at, I know what you're trying to do ;o)
You could write a quick extension, like the URL Router but smaller, to pick out the $_GET['symphony-page']
parameter and manipulate it early in the application cycle. That's the only thing I can think of.
Ok cool, and yes, It's what I'm thinking of!
Got Parent Field appending a string back to parent section entry and now I want to prettify the URL's.. an extension you say :)
Done :) Thanks for the tip John!
SOLVED
In order to detect voucher codes which are formed of a member ID prefixed with three letters I'm trying to route:
/page/MEM$voucher/
to
/page/member/$voucher/
I am currently using the following route with no success.
/page/mem:voucher/
to /page/member/:voucher/
Can anyone shed any light on what I'm doing wrong? Many thanks.
Sorry, I realised that all I needed to do was to check the "Force re-route even if page exists" option. It now works
Is it possible to select parameters or other nodes when specifying the redirect? I just updated and the shorten field extension and it no longer auto redirects so I'm new to URL routing.
I'd like to redirect from a short URL (ie: site.com/short/shorten-field.handle) to the long URL (site.come/system.ID/entry.title).
It seems the only parameters available are the page parameters by number ($1, $2, etc)
If you don't need a UI, give Routing a try... ;)
i have a redirect issue with a parent page. it has no content, and there is no link in the frontend that points to it but, it can be accessed directly; and in this case the user get a blank page with no relevant content.
and i want to perform a redirect when none of child1 or child2 is present after it
parent-page (it shoult redirect to index) parent-page/child1 (ok) parent-page/child2 (ok)
thank you
How can I make URL mysite.com/about
look like mysite.com/en/about
?
Is it even possible with this extension, or does this only rewrites parameters of certain page?
<route from="/:language/about/" to="/about/"> <filter parameter=":language" match="[a-z]{2}" /> </route>
or if about is the page name more generic:
<route from="/:language/:page/" to="/:page/"> <filter parameter=":language" match="[a-z]{2}" /> </route>
I have consistently used this route to shortcut URLs such as:
example.com/page/about/
to
example.com/about/
The page "page" accepts the parameter "$page". This works with Sym 2.3.x and URL Router 2.0.2.
On Sym 2.4 and URL Router 3.0 this no longer seems to work. Is there anything which has changed on either release which would cause this to fail? Thanks
Same problem as stuartgpalmer here...
Can anyone help me and @johnpuddephatt? I have now upgraded to Sym 2.5 and its still not working. It looks as if something in URL Router might have been broken post Sym 2.4.
Please log any bugs to the github repos, thank you.
When you do please include any information in your Symphony logs!
Are there any errors anywhere? What happens instead?
This is the changelog between 2.0.2 and 3.0, nothing jumps out. Does 2.0.2 work with 2.4 or 2.5? There doesn't appear to be any changes that would prevent 2.0.2 from working on 2.4+?
@brendo, I checked version 2.0.2 with Sym 2.5 and it also doesn't work.
I don't see any errors, I am simple sent to the index
page rather than the page
page. Its as if Debug data looks like this:
<root-page>home</root-page> <current-page>home</current-page> <current-page-id>1</current-page-id> <current-path>/who-we-are</current-path>
The index page isn't setup to accept URL parameters. If I disable the extension I then get a 404.
Nothing is included in the logs.
I'm happy to provide sum login details if anyone would be happy to have a look.
Also logged as an issue in Github
I can't get my head around routing and redirects.
Route from /$1/pagename/ to /pagename/$1/
doesnt work, but redirect does. But I want to have it silently.
What am I doing/thinking wrong?
Create an account or sign in to comment.
@bzerangue
Heeeh: Tick the checkbox for "Force re-route even if page exists".