MyBB Community Forums

Full Version: Can we remove index.php after the domain name ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hey guys,

Can we remove index.php after the domain name ? Like my website link show like this

domain.com/index.php

Regards.
Just share the domain.com link with others.

If you're talking about the logo link in the header template for home page you would go to Header Templates --> header and find
<a href="{$mybb->settings['bburl']}/index.php"><img src="{$theme['logo']}" alt="{$mybb->settings['bbname']}" title="{$mybb->settings['bbname']}" /></a>

Or something similar, depending upon your theme and just remove the /index.php from the url.
The logo link is a good catch. There's also the first element of the breadcrumb to consider. To change that would require either a basic plugin or a core edit of line 1075 of global.php from:
$navbits[0]['url'] = $mybb->settings['bburl'].'/index.php';
to:
$navbits[0]['url'] = $mybb->settings['bburl'];
Didn't even think about that part.

Typically for core edits I actually use the patches plugin by frostschutz. I know its older but it still works and is great considering any upgrades that overwrite files means I can easily just re-activate the patch without having to alter the actual files themselves.
(2023-06-14, 10:57 PM)Taylor M Wrote: [ -> ]Just share the domain.com link with others.

If you're talking about the logo link in the header template for home page you would go to Header Templates --> header and find
<a href="{$mybb->settings['bburl']}/index.php"><img src="{$theme['logo']}" alt="{$mybb->settings['bbname']}" title="{$mybb->settings['bbname']}" /></a>

Or something similar, depending upon your theme and just remove the /index.php from the url.

(2023-06-15, 09:04 AM)Laird Wrote: [ -> ]The logo link is a good catch. There's also the first element of the breadcrumb to consider. To change that would require either a basic plugin or a core edit of line 1075 of global.php from:
$navbits[0]['url'] = $mybb->settings['bburl'].'/index.php';
to:
$navbits[0]['url'] = $mybb->settings['bburl'];

Both method worked as I have 4 themes. Moreover, only have to remove index.php from logout and theme selector. Can you guide for it ?
member.php line 1960

you could try editing
redirect("index.php", $lang->redirect_alreadyloggedout);
to this
redirect($mybb->settings['bburl'], $lang->redirect_alreadyloggedout);

i'm not sure this would work but it might


for the theme selector it is a cookie that is set. the page will refresh to whichever page they selected a different theme from. if they do it from the homepage it refreshes to index.php as that is the file being loaded. I am unsure of a way to remove this.

also: no need to PM me to look at this thread again, i automatically get subscription PM's any time a thread I am in is responded to. thanks.
(2023-06-15, 08:21 PM)Taylor M Wrote: [ -> ]member.php line 1960

you could try editing
redirect($mybb->settings['bburl'], $lang->redirect_alreadyloggedout);
to this
redirect("index.php", $lang->redirect_alreadyloggedout);

i'm not sure this would work but it might


for the theme selector it is a cookie that is set. the page will refresh to whichever page they selected a different theme from. if they do it from the homepage it refreshes to index.php as that is the file being loaded. I am unsure of a way to remove this.

also: no need to PM me to look at this thread again, i automatically get subscription PM's any time a thread I am in is responded to. thanks.

Worked. Only Theme Selector index issue is remaining.
(2023-06-15, 01:04 PM)Taylor M Wrote: [ -> ]Typically for core edits I actually use the patches plugin by frostschutz. I know its older but it still works and is great considering any upgrades that overwrite files means I can easily just re-activate the patch without having to alter the actual files themselves.

Nice. I've not used it before but will keep it in mind if I need persistent core edits that aren't handled by a plugin. I seem to remember Omar mentioning a core edit plugin too recently - I'm not sure if it's the same one.

(2023-06-15, 08:52 PM)jkcool Wrote: [ -> ]Only Theme Selector index issue is remaining.

Try replacing line 5465 of inc/functions.php:
	if(!empty($_SERVER['SCRIPT_NAME']))
with:
[Note: this code supplied below is buggy, which is why I've struck it out. I'll supply working code in an update post.]
	$location = false;
	if(!empty($_SERVER['REQUEST_URI']))
	{
		$https = !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
		$scheme = $https ? 'https://' : 'http://';
		$script_loc = $scheme.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
		if(explode($mybb->settings['bburl'], $script_loc) == array('', '/index.php'))
		{
			$location = htmlspecialchars_uni(substr($_SERVER['REQUEST_URI'], 0, -strlen('/index.php')));
		}
	}
	if($location === false)
	{
		// Do nothing - $location was already set above.
	}
	elseif(!empty($_SERVER['SCRIPT_NAME']))


If that works, then the core edit plugin referenced by Taylor above might help to maintain it across MyBB ugrades.
Yes I use that patches plugin, it's too useful for core edits .
(2023-06-16, 09:21 AM)PARADOX987 Wrote: [ -> ]Yes I use that patches plugin, it's too useful for core edits .

Good to know.

Also: just a heads-up that I edited the replacement code in my last reply because it assumed MyBB was installed in a sub-directory rather than the domain root directory.
Pages: 1 2