This Mod creates and allows you do do some More SEF Options while using the default SMF SEF Urls.
You can have action urls be SEF Friendly, Page urls (from Tinyportal), and even Single Category urls be SEF friendly.
As well you can also choose to use /? or /index instead of /index.php as your scripturl string.
All options come with a shutoff that you can add to your Settings.php incase enabling one of these options causes your server to fail. Just add the following to your Settings.php if your site fails to load or work after changing SEF options to disable them.
$disable_sef = true;
Manuel İnstallation for SMF 2.0 Beta 4
Sources/ManageSettings.php
Find
);
if ($return_config)
return $config_vars;
Beforee add..
'',
// Action SEF URLS?
array('check', 'enableActionurls'),
array('check', 'enableSubActionurls'),
array('check', 'enableCurls'),
array('check', 'enablePageurls'),
array('check', 'enableUseQuestion'),
array('check', 'enableNoIndex'),
array('check', 'enableNoFile'),
Sources/QueryString.php
Find
global $board, $topic, $boardurl, $scripturl, $modSettings, $smcFunc;
Replace With
global $board, $topic, $boardurl, $scripturl, $modSettings, $smcFunc, $disable_sef;
Find
// Makes it easier to refer to things this way.
$scripturl = $boardurl . '/index.php';
Add After
if(!empty($modSettings['enableUseQuestion']) && empty($disable_sef))
$scripturl = str_replace('/index.php', '/?', $scripturl);
elseif(!empty($modSettings['enableNoIndex']) && empty($disable_sef))
$scripturl = str_replace('/index.php', '/index', $scripturl);
// This will make all urls use a double /, but it is needed for detection by the script.
elseif(!empty($modSettings['enableNoFile']) && empty($disable_sef))
$scripturl = str_replace('/index.php', '//', $scripturl);
Find
function ob_sessrewrite($buffer)
{
Add After
global $disable_sef;
Find
// If $scripturl is set to nothing, or the SID is not defined (SSI?) just quit.
add before
// Clean URL to start with.
$sef_urls = array();
// Check the Settings, with a backup.
if(!empty($modSettings['enableActionurls']) && empty($disable_sef))
$sef_urls[] = 'action';
if(!empty($modSettings['enableSubActionurls']))
$sef_urls[] = 'sa';
if(!empty($modSettings['enableCurls']) && empty($disable_sef))
$sef_urls[] = 'c';
if(!empty($modSettings['enablePageurls']) && empty($disable_sef))
$sef_urls[] = 'page';
// After all that, Rip it up and drop it in a single line.
$sef_urls = implode('|', $sef_urls) . '|';
find
$buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?(?:' . SID . ';)((?:
Replace with
$buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?(?:' . SID . ';)((?:' . $sef_urls . '
Find
$buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?((?:
Replace with
$buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?((?:' . $sef_urls . '
Find
if (empty($_COOKIE) && SID != '' && empty($context['browser']['possibly_robot']) && @version_compare(PHP_VERSION, '4.3.0') != -1)
Replace With
if (empty($_COOKIE) && SID != '' && empty($context['browser']['possibly_robot']) && @version_compare(PHP_VERSION, '4.3.0') != -1 && (empty($modSettings['enableNoFile']) || !empty($disable_sef)))
Find
if (isset($_GET['debug']))
Replace with
if (isset($_GET['debug']) && !empty($disable_sef))
Find
// Return the changed buffer.
return $buffer;
Add before
// If we are using SEF urls, we want a clean debug.
if (isset($_GET['debug']) && empty($disable_sef))
$buffer = str_replace($scripturl, substr($scripturl, 0, -1) . 'debug', $buffer);
// Maybe we want to clean slashes?
elseif(!empty($modSettings['enableNoFile']) && empty($disable_sef))
$buffer = str_replace($scripturl, substr($scripturl, 0, -2), $buffer);
Sources/Subs.php
Find
// Put the session ID in.
Add before
// Clean URL to start with.
$sef_urls = array();
// Check the Settings..
if(!empty($modSettings['enableActionurls']))
$sef_urls[] = 'action';
if(!empty($modSettings['enableSubActionurls']))
$sef_urls[] = 'sa';
if(!empty($modSettings['enableCurls']))
$sef_urls[] = 'c';
if(!empty($modSettings['enablePageurls']))
$sef_urls[] = 'page';
// After all that, Rip it up and drop it in a single line.
$sef_urls = implode('|', $sef_urls) . '|';
Find
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\?(?:' . SID . ';)((?:board|topic)=[^#]+?)(#[^"]*?)?$/e', "\$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html\$2?' . SID", $setLocation);
else
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$/e', "\$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html\$2'", $setLocation);
Replace with
$setLocation = preg_replace('/"' . preg_quote($scripturl, '/') . '\?(?:' . SID . ';)((?:' . $sef_urls . 'board|topic)=[^#"]+?)(#[^"]*?)?"/e', "'\"' . \$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html?' . SID . '\$2\"'", $setLocation);
else
$setLocation = preg_replace('/"' . preg_quote($scripturl, '/') . '\?((?:' . $sef_urls . 'board|topic)=[^#"]+?)(#[^"]*?)?"/e', "'\"' . \$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html\$2\"'", $setLocation);
Find
// We send a Refresh header only in special cases because Location looks better. (and is quicker...)
Replace with
if(!empty($modSettings['enableUseQuestion']) && empty($disable_sef))
$setLocation = str_replace('??', '?', $setLocation);
Themes/default/Post.template.php
Find
new_url = new_url.substr(0, new_url.indexOf("rand=") + 5);
Replace with
new_url = new_url.substr(0, new_url.indexOf("rand") + 5);
.htaccess
Find
?>
add before
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [QSA]
</IfModule>
Themes/default/languages/Modifications.english.php
find
?>
add before
$txt['enableActionurls'] = 'Enable Action SEF URLS';
$txt['enableSubActionurls'] = 'Enable Sub Action SEF URLS';
$txt['enableCurls'] = 'Enable Category SEF URLS (For Single Category Mod)';
$txt['enablePageurls'] = 'Enable Page SEF URLS (For Tinyportal Pages)';
$txt['enableUseQuestion'] = 'Use a question Mark (?) Instead of index.php';
$txt['enableNoIndex'] = 'Use index instead of index.php <span class="smalltext">(Doesn\'t work on all servers, use "$disable_sef = true;" in your Settings.php if enabling this breaks your site)</span>';
$txt['enableNoFile'] = 'Use Nothing instead of index.php <span class="smalltext">(Doesn\'t work on all servers, use "$disable_sef = true;" in your Settings.php if enabling this breaks your site)</span>';