Пример #1
0
function yourls_create_htaccess()
{
    $host = parse_url(YOURLS_SITE);
    $path = isset($host['path']) ? $host['path'] : '';
    $content = array('<IfModule mod_rewrite.c>', 'RewriteEngine On', 'RewriteBase ' . $path . '/', 'RewriteCond %{REQUEST_FILENAME} !-f', 'RewriteCond %{REQUEST_FILENAME} !-d', 'RewriteRule ^(.*)$ ' . $path . '/yourls-loader.php [L]', '</IfModule>');
    $filename = YOURLS_ABSPATH . '/.htaccess';
    return yourls_insert_with_markers($filename, 'YOURLS', $content);
}
Пример #2
0
function yourls_create_htaccess()
{
    $host = parse_url(YOURLS_SITE);
    $path = isset($host['path']) ? $host['path'] : '';
    $content = array('<IfModule mod_rewrite.c>', 'RewriteEngine On', 'RewriteBase ' . $path . '/', 'RewriteCond %{REQUEST_FILENAME} !-f', 'RewriteCond %{REQUEST_FILENAME} !-d', 'RewriteRule ^([0-9A-Za-z]+)/?$ ' . $path . '/yourls-go.php?id=$1 [L]', 'RewriteRule ^([0-9A-Za-z]+)\\+/?$ ' . $path . '/yourls-infos.php?id=$1 [L]', 'RewriteRule ^([0-9A-Za-z]+)\\+all/?$ ' . $path . '/yourls-infos.php?id=$1&all=1 [L]', '</IfModule>');
    $filename = dirname(dirname(__FILE__)) . '/.htaccess';
    return yourls_insert_with_markers($filename, 'YOURLS', $content);
}
Пример #3
0
/**
 * Create .htaccess or web.config. Returns boolean
 *
 */
function yourls_create_htaccess()
{
    $host = parse_url(YOURLS_SITE);
    $path = isset($host['path']) ? $host['path'] : '';
    if (yourls_is_iis()) {
        // Prepare content for a web.config file
        $content = array('<?' . 'xml version="1.0" encoding="UTF-8"?>', '<configuration>', '    <system.webServer>', '        <security>', '            <requestFiltering allowDoubleEscaping="true" />', '        </security>', '        <rewrite>', '            <rules>', '                <rule name="YOURLS" stopProcessing="true">', '                    <match url="^(.*)$" ignoreCase="false" />', '                    <conditions>', '                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />', '                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />', '                    </conditions>', '                    <action type="Rewrite" url="' . $path . '/yourls-loader.php" appendQueryString="true" />', '                </rule>', '            </rules>', '        </rewrite>', '    </system.webServer>', '</configuration>');
        $filename = YOURLS_ABSPATH . '/web.config';
        $marker = 'none';
    } else {
        // Prepare content for a .htaccess file
        $content = array('<IfModule mod_rewrite.c>', 'RewriteEngine On', 'RewriteBase ' . $path . '/', 'RewriteCond %{REQUEST_FILENAME} !-f', 'RewriteCond %{REQUEST_FILENAME} !-d', 'RewriteRule ^.*$ ' . $path . '/yourls-loader.php [L]', '</IfModule>');
        $filename = YOURLS_ABSPATH . '/.htaccess';
        $marker = 'YOURLS';
    }
    return yourls_insert_with_markers($filename, $marker, $content);
}