Forums

Unfortunately no one can be told what FluxBB is - you have to see it for yourself.

You are not logged in.

#1 2019-10-30 19:14:04

Peeteris
Member
Registered: 2019-10-06
Posts: 50

Trailing slash; redirecting and languages; sitemap

Hi FluxBB users!

I've redirected some URLs (like /userlist.php to /userlist and so on) and that works, but, if I change language (using option in footer), it changes the language, but also redirects to index.php.
If I change language on /userlist.php, after redirecting it still stays on userlist.php page.
If I change language on /userlist, after redirecting it redirects to /index.php
How and where I can change that?
Also, maybe I'm doing it wrong and there is a proper way to get rid of .php extensions for pages with FluxBB?
----
On my site various if not all pages are accessible with trailing slash which by search engines is considered bad, because of duplicate content.
E.g. I can access proper page: URL/search.php and URL/search.php/ which will give out the same page, but without any images and styles.
This can be tackled only with redirecting in server? The problem is - I'm using lighttpd and that means that I'll have to manually write in every redirect in lighttpd.conf
----
Original message, partially solved:

How are you dealing with Sitemap(s)?
As Forum is a place where content is created daily, stock sitemap generators doesn't really help.
Is there any script or modification that you are using for your forums to be SEO friendly?

Also, does robots.txt somehow affect the SEO?

User-agent: *
Disallow: /a
Disallow: /d
Disallow: /c
Disallow: /e
Disallow: /j
Disallow: /l
Disallow: /m
Disallow: /p
Disallow: /r
Disallow: /s
Disallow: /u
Disallow: /*pid=

User-agent: Yandex
Disallow: /a
Disallow: /d
Disallow: /c
Disallow: /e
Disallow: /j
Disallow: /l
Disallow: /m
Disallow: /p
Disallow: /r
Disallow: /s
Disallow: /u
Disallow: /*pid=
Crawl-delay: 5
Clean-param: search_hl
Clean-param: csrf_hash

Thank you!

Last edited by Peeteris (2019-11-02 13:07:07)

Offline

#2 2019-10-31 13:49:56

Franz
Lead developer
From: Germany
Registered: 2008-05-13
Posts: 6,719
Website

Re: Trailing slash; redirecting and languages; sitemap

Hey, have you taken a look at this modification?


fluxbb.de | develoPHP

"As code is more often read than written it's really important to write clean code."

Offline

#3 2019-10-31 15:36:01

Peeteris
Member
Registered: 2019-10-06
Posts: 50

Re: Trailing slash; redirecting and languages; sitemap

Franz wrote:

Hey, have you taken a look at this modification?

I tried it out, but when I ran test at https://www.ionos.com/tools/website-checker, it showed that there's no sitemap being used.

Offline

#4 2019-11-02 12:55:41

Peeteris
Member
Registered: 2019-10-06
Posts: 50

Re: Trailing slash; redirecting and languages; sitemap

Franz wrote:

Hey, have you taken a look at this modification?

I found out that opening URL/sitemap.php will show an XML file of sitemap.

Not that automatic, but I can at least manually every 2nd week open URL/sitemap.php , copy page source and paste in sitemal.xml.

Not sure if this is how it was supossed to be, but at least it works.

Offline

#5 2019-11-13 18:49:21

Peeteris
Member
Registered: 2019-10-06
Posts: 50

Re: Trailing slash; redirecting and languages; sitemap

I've fixed 2 of 3 problems, but I still need help with this one:

I've redirected some URLs (like /userlist.php to /userlist and so on) and that works, but if I change language (using option in footer), it changes the language, but also redirects to index.php and doesn't stay on page where I changed language.
If I change language in site/userlist.php, after redirecting it still stays on userlist.php page.
If I change language on site/userlist, after redirecting it redirects to /index.php
How and where I can change that?

Thank you!

Offline

#6 2019-11-13 23:51:51

Franz
Lead developer
From: Germany
Registered: 2008-05-13
Posts: 6,719
Website

Re: Trailing slash; redirecting and languages; sitemap

That option in the footer... is that from a modification? If so, which one?


fluxbb.de | develoPHP

"As code is more often read than written it's really important to write clean code."

Offline

#7 2019-11-14 02:14:35

Visman
Member
From: Siberia
Registered: 2010-07-10
Posts: 1,381
Website

Re: Trailing slash; redirecting and languages; sitemap

The code is responsible for switching the language from the footer:
footer.php

// START быстрое переключение языка - Visman
if (!isset($languages) || !is_array($languages))
	$languages = forum_list_langs();

$lang_temp = '';
if (count($languages) > 1)
{
	$lang_temp .= "\t\t\t\t".'<form id="qjump2" action="misc.php" method="get">'."\n\t\t\t\t\t".'<div><label>'."\n\t\t\t\t\t\t".'<input type="hidden" name="csrf_hash" value="'.csrf_hash('misc.php').'" />'."\n\t\t\t\t\t\t".'<input type="hidden" name="action" value="lang" />'."\n\t\t\t\t\t\t".'<select name="lang" onchange="this.form.submit()">'."\n";
	foreach ($languages as $temp)
	{
		if ($pun_user['language'] == $temp)
			$lang_temp .= "\t\t\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.$temp.'</option>'."\n";
		else
			$lang_temp .= "\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.$temp.'</option>'."\n";
	}
	$lang_temp .= "\t\t\t\t\t\t".'</select></label>'."\n\t\t\t\t\t\t".'<input id="qjump2input" type="submit" value="'.$lang_common['Go'].'" />'."\n\t\t\t\t\t".'</div>'."\n\t\t\t\t".'</form>'."\n";

	$page_js['c'][] = 'if (document.getElementById("qjump2input")) document.getElementById("qjump2input").style.display = "none";';
}
// END быстрое переключение языка - Visman

.....


echo $lang_temp; // быстрое переключение языка - Visman

misc.php

// START быстрое переключение языка - Visman
else if ($action == 'lang')
{
	confirm_referrer('misc.php');

	$language = isset($_GET['lang']) ? preg_replace('%[^\w]%', '', pun_trim($_GET['lang'])) : '';
	if (empty($language) || !file_exists(PUN_ROOT.'lang/'.$language.'/common.php'))
		message($lang_common['Bad request'], false, '404 Not Found');

	if ($pun_user['is_guest'])
	{
		forum_setcookie($cookie_name.'_glang', $language, time()+ 31536000);
	}
	else
		$db->query('UPDATE '.$db->prefix.'users SET language="'.$db->escape($language).'" WHERE id='.$pun_user['id']) or error('Unable to update profile', __FILE__, __LINE__, $db->error());

	// Try to determine if the data in HTTP_REFERER is valid (if not, we redirect to index.php after login)
	if (!empty($_SERVER['HTTP_REFERER']))
		$redirect_url = validate_redirect($_SERVER['HTTP_REFERER'], null);

	if (!isset($redirect_url))
		$redirect_url = get_base_url(true).'/index.php';
	else if (preg_match('%viewtopic\.php\?pid=(\d+)$%', $redirect_url, $matches))
		$redirect_url .= '#p'.$matches[1];

	redirect($redirect_url, $lang_misc['Lang changed']);
}
// END быстрое переключение языка - Visman

Offline

#8 2019-11-15 05:26:36

Peeteris
Member
Registered: 2019-10-06
Posts: 50

Re: Trailing slash; redirecting and languages; sitemap

Oh I forgot this feature isn't present in unmodified version.
As far as I understand, it's a problem with referrer which recognizes (for example) /search.php, but not /search.
But where is that referrer info located and how to modify it to understand links without extensions; that's the question.

Offline

Board footer

Powered by FluxBB