#1
Dear DC,
Good day, when i share my website link in facebook. and some one click it can not get the page. the fbclid is the problem. how to solve this issue. . how to remove this and redirect my website. thanks
#2
Hi investobd,

I do not entirely understand your question but I'll give it a go.

You are experiencing an issue with sharing your website link on Facebook and the problem appears to be related to the "fbclid" parameter in the URL causing an inability to access the page - if so:The above checks if the "fbclid" parameter is present in the URL. If found, it removes the parameter and redirects to the clean URL using a 301 (permanent) redirect.
#3
when someone click my share link in facebook, its go to https://www.domain.com/?fbclid=token . i try your code and other some code . it redirect 404 page.
if i share https://www.domain.com/welcome there is no problem but if i share https://www.domain.com/ then show the 404
#4
OK investobd, I think I have got this now.

If you have a read of the docs at 'https://trongate.io/docs/chapter_intro/understanding-routing' you will see Trongate has been designed with a 'segment-based' approach. Meaning, segments 1 & 2 are reserved.

If I quote from the docs: "Trongate follows a simple set of rules for mapping a URL to a particular module and method. The rules for basic URL routing are:

- assume the first URL segment to be the name of the module and class to be loaded
- assume the second URL segment to be the name of the method that is to be invoked
- assume the third segment (if there is one) to be the value that is to be passed into the method"

Let's use your URL as an example- segment(1); would equal 'welcome'; and is reserved for the module name (you can't pass https://www.domain.com/?fbclid=token)
- segment(2); would equal 'index', and is reserved for the method name
- segment(3); would equal '?fbclid=token'.

So if you share a link on Facebook you MUST pass the domain, module name and method (and always add a forward slash '/' at the end) then Facebook will add ?fbclid=token at the end of the URL. Like so:

You could add this code to your endpoint to see if the user landed on this page from Facebook:

I hope that has helped.
#5
** UPDATE ** - Sadly, I managed to catch COVID over Christmas which has left me rather isolated and time on my hands, so thought I'd take another look at this.

In the past, I've seen other Trongate users complain that they can't use "query parameters" or "query string parameters." on the URL for segment(1) and segment(2)So you're not the first to have this issue.

After a bit of playing around in Core.php, I have it all working :)

Just swap out 'function serve_controller()' in Core.php with this:


You should now be able to share links on Facebook. e.g https://www.domain.com and Facebook will add ?fbclid=token to the URL which will now work with a Trongate site.

You can also read these "query parameters" using the super global '$_GET'

For example
and if you open your 'DEFAULT_CONTROLLER' and edit your 'DEFAULT_METHOD'

Note: Also works with a custom modules

Cheers,
Si

** Another Update **
I have now pushed this fix to GitHub, so when you create a new app via the Desktop app it will just work.