Clean URLs

Please post answers on the most frequently asked questions about CMSimple
Maxim
Posts: 121
Joined: Thu Jun 13, 2013 6:52 am
Location: Запорожье
Contact:

Почему нельзя пользоваться переменными в .htaccess?

Post by Maxim » Wed Apr 09, 2014 4:00 am

[ external image ] Почему нельзя пользоваться переменными в .htaccess? Переменные в .htaccess:
[ external image ] Warum kann ich keine Variablen in. htaccess? Variablen in. htaccess:
[ external image ] Why can not I use variables in .htaccess? Variables in .htaccess:
http://f9r.ru/mod_rewrite.acti.vars.html
http://rapidup.ru/stati/Htaccess_Rewrit ... imery.html
Simple Hosting
Бедная, бросаемая бурею, безутешная!

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Clean URLs

Post by cmb » Wed Apr 09, 2014 11:07 am

Maxim wrote:Многое не понял нужно добавлять или нет. Этот код не добавлял:
This code would be necessary to have internationalized names for login, sitemap, print and mailform. I'm not sure, however, if that would still work with CMSimple_XH 1.6(.x).
Maxim wrote:Как не печатать:
The code in my former post should suppress the printlinks for mailform, sitemap and login.
Maxim wrote:Почему нельзя пользоваться переменными в .htaccess? Переменные в .htaccess:
.htaccess doesn't know anything about PHP, because it is processed before the PHP. So it is not possible to inform .htaccess about any configuration made in CMSimple_XH.
Last edited by cmb on Wed Apr 09, 2014 11:39 am, edited 1 time in total.
Reason: fixed link
Christoph M. Becker – Plugins for CMSimple_XH

Maxim
Posts: 121
Joined: Thu Jun 13, 2013 6:52 am
Location: Запорожье
Contact:

Допустил ошибку

Post by Maxim » Wed Apr 09, 2014 11:21 am

cmb wrote:
Maxim wrote:[ external image ] Как не печатать:
[ external image ] The code in my former post should suppress the printlinks for mailform, sitemap and login.
[ external image ] Не понял, что это за ссылка?
[ external image ] Nicht verstanden, was das für ein Link?
[ external image ] Did not understand, what is that link?

[ external image ] ...CMSimple_XH-161-CleanURLs-2014-04-08 - допустил ошибку.
[ external image ] ...CMSimple_XH-161-CleanURLs-2014-04-08 - ein Fehler unterlaufen.
[ external image ] ...CMSimple_XH-161-CleanURLs-2014-04-08 - made a mistake.

[ external image ] ...CMSimple_XH-161-CleanURLs-2014-04-09 - сегодня утром разместил на сайте.
[ external image ] ...CMSimple_XH-161-CleanURLs-2014-04-09 - heute morgen veröffentlicht auf der Website.
[ external image ] ...CMSimple_XH-161-CleanURLs-2014-04-09 - this morning posted on the website.
Simple Hosting
Бедная, бросаемая бурею, безутешная!

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Clean URLs

Post by cmb » Wed Apr 09, 2014 11:40 am

Maxim wrote:Не понял, что это за ссылка?
Sorry, the link was wrong. I fixed it now.
Christoph M. Becker – Plugins for CMSimple_XH

Maxim
Posts: 121
Joined: Thu Jun 13, 2013 6:52 am
Location: Запорожье
Contact:

Print view на главной странице сайта

Post by Maxim » Wed Apr 09, 2014 12:50 pm

[ external image ] СПАСИБО!!! Завтра исправлю.
[ external image ] VIELEN DANK!!! Morgen korrigieren.
[ external image ] THANK YOU!!! Tomorrow will fix it.

[ external image ] Когда на главной странице сайта выбираю "Print view":
[ external image ] Wenn auf der Homepage wähle "Print view":
[ external image ] When on the main page of the site choose the "Print view":
/&print.html

[ external image ] Сложно создать такой вид?:
[ external image ] Schwierig ist, eine solche Art?:
[ external image ] It is difficult to create such a view?:
/Welcome_to_CMSimple_XH&print.html
Simple Hosting
Бедная, бросаемая бурею, безутешная!

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Clean URLs

Post by cmb » Wed Apr 09, 2014 5:22 pm

Maxim wrote:Сложно создать такой вид?:
/Welcome_to_CMSimple_XH&print.html
Well, the cleaner solution would be to redirect users to Welcome_to_CMSimple_XH in the first place. (As it is now, there is duplicate content, what should generally be avoided.) This could be done by modifying cmsimple/cms.php. Find the following line:

Code: Select all

rfc(); // Here content is loaded     
Add the following code directly below this line:

Code: Select all

if ($_SERVER['REQUEST_METHOD'] == 'GET' && empty($_GET)) {
    header('Location: ' . CMSIMPLE_URL . '?' . $u[0]);
    exit;
} 
Then the printlink will point to the desired location. However, that doesn't solve the duplicate content issue[1], what could be done with the following:

Code: Select all

if ($_SERVER['REQUEST_METHOD'] == 'GET' && empty($_GET)) {
    header('Location: ' . CMSIMPLE_URL . '?' . $u[0], true, 301);
    exit;
} 
However, I have to strongly recommend not to use this second solution, because clients having cached the 301 Moved Permanently may not look again, and so changing the heading of the start page might cause those clients to get a 404 Not found when requesting the domain directly.

[1] To solve this very duplicate content issue, one can use the Canonical Plugin.
Christoph M. Becker – Plugins for CMSimple_XH

Maxim
Posts: 121
Joined: Thu Jun 13, 2013 6:52 am
Location: Запорожье
Contact:

Я не об этом говорил

Post by Maxim » Thu Apr 10, 2014 5:30 am

[ external image ] СПАСИБО!!!
[ external image ] VIELEN DANK!!!
[ external image ] THANK YOU!!!

[ external image ] Я не об этом говорил. Когда находишься на главной странице сайта и выбираешь "Login" у ссылки такой вид:
[ external image ] Ich habe nicht darüber gesprochen. Wenn man auf der Homepage und wählen Sie "Login" bei den Links so Aussehen:
[ external image ] I don't talked about this. When you're on the main page, and select "Login" link to look like this:
/Welcome-to-CMSimple_XH&login.html

[ external image ] Хочется такой же принцип и для "Print view". Страница по умолчанию:
[ external image ] Wollen wir dasselbe Prinzip für "Print view". Der Standard:
[ external image ] I want the same principle to "Print view". The default page:
/

[ external image ] Только при печати:
[ external image ] Nur beim drucken:
[ external image ] Only when printing:
/Welcome-to-CMSimple_XH&print.html

[ external image ] Добавил этот код:
[ external image ] Hinzugefügt diesen Code ein:
[ external image ] Added this code:

Code: Select all

$su = substr($su, 0, $cf['uri']['length']);

foreach (array('login', 'mailform', 'print', 'sitemap') as $i) {
    if (!empty($GLOBALS[uenc($tx['menu'][$i])])) {
        $$i = 'true';
    }
}
Simple Hosting
Бедная, бросаемая бурею, безутешная!

tanavots
Posts: 72
Joined: Sat Feb 25, 2012 4:18 pm

Re: Clean URLs

Post by tanavots » Fri Apr 11, 2014 6:03 am

Hey!

Found, that CleanURL not working if domain name is as http://www.domain.ee/~name/
Main page is working fine, but not any of links.

e.g. http://www.domain.ee/~name/Languages
give error
Not Found
The requested URL /home/name/public_html/ was not found on this server.

Tested with CMSimple 1.57, 1.59, 1.6 and 1.6.1.
Any idea?

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Clean URLs

Post by cmb » Mon Apr 14, 2014 10:54 am

Maxim wrote:Я не об этом говорил. Когда находишься на главной странице сайта и выбираешь "Login" у ссылки такой вид:
/Welcome-to-CMSimple_XH&login.html

Хочется такой же принцип и для "Print view". Страница по умолчанию:
/

Только при печати:
/Welcome-to-CMSimple_XH&print.html
Find function XH_printUrl() in cmsimple/tplfuncs.php and replace it with the following:

Code: Select all

function XH_printUrl()
{
    global $f, $search, $file, $sn, $u;

    $t = '&print';
    if ($f == 'search') {
        $t .= '&function=search&search=' . stsl($search);
    } elseif ($f == 'file') {
        $t .= '&file=' . $file;
    } elseif ($f != '' && $f != 'save') {
        $t .= '&' . $f;
    } elseif (sv('QUERY_STRING') != '') {
        $t = sv('QUERY_STRING') . $t;
    } else {
        $t = $u[0] . $t;
    }
    $t = XH_hsc($t);
    return $sn . '?' . $t;
}
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Clean URLs

Post by cmb » Mon Apr 14, 2014 11:01 am

tanavots wrote:Found, that CleanURL not working if domain name is as http://www.domain.ee/~name/
Main page is working fine, but not any of links.

e.g. http://www.domain.ee/~name/Languages
give error
Not Found
The requested URL /home/name/public_html/ was not found on this server.

Tested with CMSimple 1.57, 1.59, 1.6 and 1.6.1.
Any idea?
You can try the following .htaccess instead (not sure if that'll work):

Code: Select all

RewriteEngine on

# set the rewrite base to the user directory
RewriteBase /~name/

# Do not rewrite requests to existing directories and files:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Everything else is a CMSimple_XH page request,
# so shift the subfolders to the beginning of the query string
RewriteRule ^([A-z]{2}/)?(.*)$ $1?$2 [QSA]
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply