How to delete facebook parameters that puts the url's shared on your wall in codeigniter links - facebook

When I share a link http://www.totalrunning.com/results/misFotos/TTRCAR1346364033/283 (Codeigniter Url's) on my Facebook wall appears fine but when clicking the resulting URL is: http://www.totalrunning.com/results/misFotos/TTRCAR1346364033/283?fb_action_ids=441641579216005&fb_action_types=og.likes&fb_source=aggregation&fb_aggregation_id=288381481237582
fb_action_ids added among other parameters this causes the url not resolving correctly
That I can do to make facebook not put those parameters in my url or like handling with Codeigniter ???
Thanks

Enabling Query Strings
In some cases you might prefer to use query strings URLs:
index.php?c=products&m=view&id=345
CodeIgniter optionally supports this capability, which can be enabled in your application/config.php file. If you open your config file you'll see these items:
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
If you change enable_query_strings to TRUE this feature will become active. Your controllers and functions will then be accessible using the "trigger" words you've set to invoke your controllers and methods:
index.php?c=controller&m=method
You can read more at the Code Ignitor user-guide here: http://codeigniter.com/user_guide/general/urls.html

The solution I found was through the same file using Codeigniter .htaccess to hide the index.php
Above this htaccess put the following:
# -----------------
RewriteCond% {QUERY_STRING} ^ fb_action_ids = (. *) $ [NC]
RewriteRule ^ (. *) $ / $ 1? [R = 301, L]
# -----------------
with this code you tell the server that elime the query string of the url but only when he comes fb_action_ids or any parameter you choose not prevent the proper functioning of query strings in CodeIgniter
With this you can preserves the beautiful codeigniter urls and facebook links resolved correctly!
Important: Put it up to avoid file overwrite functionality to hide the index.php

I wouldn't recommend this method. Just add a slash after your final parameter and it will work fine. It will ignore all those facebook extras

Related

Dynamic Links from a CMS - Error: "redirect" can not be returned from getStaticProps during prerendering

I have a Next JS app connected to a CMS and hosted on Vercel - all links are dynamic and the pages are created by the content authors.
I am trying to create dynamic redirects that will force URLs to adhere to formats that are better for SEO. For example:
Enforce lowercase URLs
Replace spaces with dashes
Remove trailing slashes
For example, /test/Author Name/ would redirect to /test/author-name
Since I need to trigger a 301 redirect for these wrong URLs, the only way to do this with Next JS from what I have found is to return a Redirect from getStaticProps, this is what I have so far:
export const getStaticProps: GetStaticProps = async (context) => {
let requestedUrl = '/';
if (context?.params?.path) {
requestedUrl = '/' + (context?.params?.path as string[]).join('/');
}
//check for URLs with uppercases, spaces, etc. and clean them up
let modifiedUrl = requestedUrl;
modifiedUrl = modifiedUrl.trim().toLowerCase().replace(/\s\s+/g, ' ').replace(/\s/g, '-');
if (modifiedUrl != requestedUrl) {
return {
redirect: {
destination: modifiedUrl,
permanent: true,
},
};
}
This works wonderfully well running locally and connected to the CMS - everything is working as it should and all "faulty" URLs are corrected with the correct response code.
Sadly, this does not work on build, I have spent so much time so far trying to find an alternative, but no matter what I do, the build on Vercel fails with the error:
"redirect" can not be returned from getStaticProps during prerendering
The next best potential solution is to use Middleware, but that requires v.12 at least. Due to limitations from the CMS connector, we are forced to use Node v.11 :(
The alternative that I have built is to use router.push on the client side, but this... just looks terrible. The page loads, returns a 200, and then loads again with the corrected URL. Not good for the user's experience.
Any advice or suggestions? I am baffled that something this simple is this complicated with Next JS!
I resolved the issue... it looks like redirects on statically generated pages are not possible unfortunately. I removed getStaticProps and getStaticPaths, and added getServerSideProps instead. The redirects are now working correctly, but the site is not as fast as we are losing out on SSG.

nginx redirect old site urls and modify 1 language suffix only

I want to redirect old site urls to new site. But new site has different page names and language chars have changed too.
for example:
en/about/info will redirect to en/com/information
but
ge/about/info will go to ka/com/information
map $request_uri $redirect_uri {
<lang>/about/info/ $lang/com/information/
}
any ideas how I would go about this? There are a lot of urls, so I don't want to write these urls hardcoded for each language.
The map directive can capture parts of a regular expression, but cannot use that capture in the mapped result.
So it is possible to create a named capture called lang (for example) and use it after the mapped variable is evaluated. For example:
map $request_uri $redirect_uri {
~*(?<lang>/\w\w/)about/info/ com/information/;
}
And in the server or location block:
if ($redirect_uri) {
return 301 $lang$redirect_uri;
}
Note that $lang is only created after the value of $redirect_uri is evaluated in the if statement.
See this document for details.

In AEM/CQ5 , URL redirection using /etc/map not working

I have a use case to redirect /content/project/en/test/events to /content/project/en/test page as internal redirection of page properties is not working .
I used following values under /etc/map/http folder :
sling:match as (.+)/en/test/(.+)$
sling:internalRedirect as (.+)/en/test.html
Still my required redirection is not working .
Please let me know correct configuration for the same .
Thanks&Regards.
The sling:internalRedirect is the target to which user is taken so you should use in it the match from the sling:match
use: sling:internalRedirect as $1/en/test.html
btw. there's a useful article about mappings here: https://www.cognifide.com/our-blogs/cq/multidomain-cq-mappings-and-apache-configuration/
EDIT:
a simple config like this will work (redirect from home.html to page1.html):

Redirect user to mobile site and back in typo3 with typoscript

I have found that if I use the below typoscript I can redirect my users to the mobile version of the site which has its own tree in the backend of my typo3 site.
[useragent = *iPhone*]||[useragent = *iPod*]||[useragent = *Android*]
config.additionalHeaders = Location: http://m.example.com/
[end]
It is a simplified version of the site however so I want to have a return to full website link. But due to my above typoscript redirecting users to the m domain i can't get back to www.example.com.
Does anyone have any typoscript suggestions here?
You need an additional parameter in your link back which you can use to turn off the redirection.
Try something like this:
# check for mobile browser
[useragent = *iPhone*]||[useragent = *iPod*]||[useragent = *Android*]
config.additionalHeaders = Location: http://m.example.com/
[global]
# undo mobile redirect if mobile param is set
[globalVar = GP:nomobileredirect > 0]
config.additionalHeaders =
[global]
and redirect to http://www.example.com/?nomobileredirect=1 on your link back.
To keep a nomobileredirect-value in all generated links, add nomobileredirect to your linkVars, e.g.
config.linkVars = nomobileredirect,L
You can use another condition on a GET parameter and override the config.additionalHeaders later. Remember, TS is not a scripting language, but rather a static configuration. The last statement always wins and rendering starts only once all TS has been parsed.
You can also try to extend the above condition by an additional exclude of a GET parameter.

feedpp and session ID

we are using Perl and cpan Modul FeedPP to parse RSS Feeds.
The Perl script runs trough the different items of the RSS Feeds and save the link to the database, liket his:
my $response = $ua->get($url);
if ($response->is_success) {
my $feed = XML::FeedPP->new( $response->content, -type => 'string' );
foreach my $item ( $feed->get_item() ) {
my $link = $item->link();
[...]
$url contains the URL to an RSS Feed, like http://my.domain/RSS/feeds.xml
in this case, $item->link() will contain links to the RSS article, like http://my.domain/topic/myarticle.html
The Problem is, some webservers (which provides the RSS feeds) does an HTTP refer in order to add an session ID to the URL, like this: http://my.domain/RSS/feeds.xml;jsessionid=4C989B1DB91D706C3E46B6E30427D5CD.
The strange think is, that feedPP seams to add this session-ID to the link of every item. So $item->link() contain links to the RSS article, like http://my.domain/topic/myarticle.html;jsessionid=4C989B1DB91D706C3E46B6E30427D5CD
Even if the original link does not contain an session ID.
Is there a way to turn of that behavior of feedPP??
Thank you for any kind of help.
I took a look through http://metacpan.org/pod/XML::FeedPP but didn't see any way to turn have the link() method trim those session IDs for you. (I'm using XML::FeedPP in one of my scripts and the site I happen to be parsing doesn't use session IDs.)
So I think the answer is no, not currently. You could try contacting the author or filing a bug.
IMHO, the behavior is correct: uri components which follow a semi-colon are defined part of the path (configuration parameter for interpretation), so when the uri is used to make a relative url into an absolute uri it needs to be copied as well.
You expect compatible behavior with '&' parameters, but they are not equal.
https://rt.cpan.org/Ticket/Display.html?id=73895