Page 1 of 1

Немогу установить ЧПУ

Posted: Wed Dec 03, 2008 4:51 am
by CryDead
$config['assume_mod_rewrite'] = true;
$config['use_hierarchy'] = true;
Файл .htaccess сделан копированием из doc/.htaccess
mod_rewrite подключен
Но все равно пишет страницу 404
P.S. AllowOverride All

Re: Немогу установить ЧПУ

Posted: Wed Dec 03, 2008 6:23 am
by von-hamster
Вот конфиг, который у меня работает:

Code: Select all

#Show mod_rewrite URLs in the menu? You must enable 'use_hierarchy' for this to work for modules
$config['assume_mod_rewrite'] = true;

#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '/';

#If you don't use mod_rewrite, then would you like to use the built-in
#pretty url mechanism?  This will not work with IIS and the {metadata} tag
#should be in all of your templates before enabling.
$config['internal_pretty_urls'] = true;

#If you're using the internal pretty url mechanism or mod_rewrite, would you like to
#show urls in their hierarchy?  (ex. http://www.mysite.com/parent/parent/childpage)
$config['use_hierarchy'] = true;

#If using none of the above options, what should we be using for the query string
#variable?  (ex. http://www.mysite.com/index.php?page=somecontent)
$config['query_var'] = 'page';

Re: Немогу установить ЧПУ

Posted: Wed Dec 03, 2008 7:36 am
by CryDead
Странно  ??? но вылечило это RewriteBase /cms .

Re: Немогу установить ЧПУ

Posted: Wed Dec 03, 2008 9:54 am
by Sonya
CryDead wrote: Странно  ??? но вылечило это RewriteBase /cms .
CMS установлен НЕ в корневой директории. Стандартно ЧПУ работает, если установлен в http://sayt.ru, а у тебя, видимо, http://sayt.ru/cms

Re: Немогу установить ЧПУ

Posted: Wed Dec 03, 2008 5:59 pm
by Il_Burbero
Неохота делать новый топик, может заглянет кто.

Короче попросили меня тут сайтик сделать. Я так подумал и поставил сразу 1.5 бета, потом обновил... И вот уже целый день ищу одну проблему.
В общем конфиг такой:

Code: Select all

#------------
#URL Settings
#------------

#Show mod_rewrite URLs in the menu? You must enable 'use_hierarchy' for this to work for modules
$config['assume_mod_rewrite'] = true;

#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '.html';

#If you don't use mod_rewrite, then would you like to use the built-in
#pretty url mechanism?  This will not work with IIS and the {metadata} tag
#should be in all of your templates before enabling.
$config['internal_pretty_urls'] = false; #пробовал и true

#If you're using the internal pretty url mechanism or mod_rewrite, would you like to
#show urls in their hierarchy?  (ex. http://www.mysite.com/parent/parent/childpage)
$config['use_hierarchy'] = true;

#If using none of the above options, what should we be using for the query string
#variable?  (ex. http://www.mysite.com/index.php?page=somecontent)
$config['query_var'] = 'page';
Конфиг хтаксесса:

Code: Select all

AddDefaultCharset UTF-8

DirectoryIndex index.html index.php
IndexIgnore *.php* *.js
DefaultLanguage ru-RU

Options +FollowSymLinks
#
<IfModule mod_rewrite.c>
RewriteEngine on
#
#Sub-dir e.g: /cmsms/
RewriteBase /
#
# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]

</IfModule>
А теперь самое интересное. Аналогичный конфиг на другом хосте и на версии 1.4 работает без проблем. Т.е. при наборе несуществующего адреса выдается либо 404 кмсное (если на локалке тестить) либо на самом хосте 404 страничка от хостера.

Проблема в следующем, на текущем хосте (другом) на версии 1.5 (параметры хоста):
Php Information:
    * phpversion: 5.2.0-8+etch7
    * md5_function: Вкл (True)
    * gd_version: 2
    * tempnam_function: Вкл (True)
    * magic_quotes_runtime: Выкл (False)
    * memory_limit: 32M
    * max_execution_time: 60
    * safe_mode: Выкл (False)
    * session_save_path: /var/lib/php5 (1733)

Server Information:
    * Server Api: cgi-fcgi
    * Server Db Type: MySQL (mysql)
    * Server Db Version: 5.0.32

при запросе несуществующей страницы выдает пустой лист и надпись

Code: Select all

Fatal error: Call to a member function GetContent() on a non-object in /home/www/login/htdocs/index.php on line 217
И я думаю эта байда из за структуры хостера. Т.е. она такая
Реальная (ту что пишу в конфе и та что дает хостер) home/www/login/htdocs/
По фтп я вижу уже home/htdocs/

При попытке вписать htdocs в хтаксесс получаю 500 по любому запросу, и сие понятно ибо я прописываю в настройках хостера папку в которой индексный файл т.е. этот долбаный htdocs.
Я в задумчивости. Покручу может еще на локале. Хотя чую что так быть не должно, должно быть либо 404 либо выбрасывать на главную, ну не может быть по левому запросу такая выдача, неправильно это. Может в php.ini добавить или убавить чего то?

Буду благодарен если кто поможет советом.

Re: Немогу установить ЧПУ

Posted: Fri Dec 05, 2008 11:30 am
by Il_Burbero
UPD потестил на локалхосте с включенным дебаггером КМСки. Тот же результат при запросе несуществующей страницы.

Что же делать? :(  ???  :-\

Re: Немогу установить ЧПУ

Posted: Fri Dec 05, 2008 2:50 pm
by ZYV
Смотреть error_log, включить rewrite_log и пытаться смотреть его (это может сделать только пользователь с правами root). У меня всё работает.

Re: Немогу установить ЧПУ

Posted: Fri Dec 05, 2008 6:20 pm
by Il_Burbero
Отлаживать rewrite можно по логу, уровень notice и директива     
    rewrite_log [on|off];
    Агмм... а как его включить этот лог ?

error_log  /path/to/error_log  notice;

http {
    rewrite_log  on;
    ...
}
Сорри за нубство но где это писать? На будущее пригодится...

Все таки дело было в кмске. Тупо обновил до 1.5.1 работает как часы :)

Re: Немогу установить ЧПУ

Posted: Fri Dec 05, 2008 7:47 pm
by ZYV
Ну то, что тебе показали - это для nginx - соответственно в настройках nginx. В Apache директива RewriteLog пишется в httpd.conf прямо так или в секции конкретного vhost.