Kayak
|
|
|
|
|
Рег.: 22.10.2004
|
Сообщений: 2432
|
|
Рейтинг: 1098
|
|
Проблема с mod_rewrite
13.06.2006 13:31
|
|
|
Мне нужно, чтобы при обращении к домену, в момент переадресации на index.php корневого каталога, заодно приписывался и параметр section=1.
То есть: http://www.domen.com -> http://www.domen.com/index.php?section=1
Я это прописал в .htaccess вот так, но оно не срабатывает. Где баг?
code:
<IfModule mod_rewrite.c> RewriteEngine on Options +FollowSymlinks RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/$ /index.php?section=1 [L] </IfModule>
|
|
kdmitrie
|
member
|
|
|
|
Рег.: 07.12.2005
|
Сообщений: 181
|
Из: нутри
|
Рейтинг: 35
|
|
Re: Проблема с mod_rewrite
[re: Kayak]
13.06.2006 14:49
|
|
|
Насколько я помню, в .htaccess такие вещи не прописываются, надо прописывать в httpd.conf.
А чем мешает в index.php смотреть, пришел ли параметр section, (или запрошеный url сверять). Если не пришел - устанавливаем section=1. Или уж, если так необходима переадресация, header("Location:...").
Редактировал kdmitrie (13.06.2006 15:00)
|
Чужой код - потемки (с) |
|
Lynn
|
'Кофеман'
|
|
|
|
Рег.: 28.02.2003
|
Сообщений: 7316
|
Из: Тропарево-Никулино
|
Рейтинг: 905
|
|
Re: Проблема с mod_rewrite
[re: Kayak]
13.06.2006 14:53
|
|
|
Попробуй RewriteRule ^$
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html:
Note: Never forget that Pattern is applied to a complete URL in per-server configuration files. But in per-directory configuration files, the per-directory prefix (which always is the same for a specific directory!) is automatically removed for the pattern matching and automatically added after the substitution has been done. This feature is essential for many sorts of rewriting, because without this prefix stripping you have to match the parent directory which is not always possible.
Редактировал Lynn (13.06.2006 14:55)
|
Плыл в небе, глубоком как сон, Кокаиновый пес - Адриан и Александр |
|
Kayak
|
|
|
|
|
Рег.: 22.10.2004
|
Сообщений: 2432
|
|
Рейтинг: 1098
|
|
|
В ответ на:
Насколько я помню, в .htaccess такие вещи не прописываются, надо прописывать в httpd.conf.
Еще как прописываются.
В index.php лезть - неконцептуально.
|
|
kdmitrie
|
member
|
|
|
|
Рег.: 07.12.2005
|
Сообщений: 181
|
Из: нутри
|
Рейтинг: 35
|
|
Re: Проблема с mod_rewrite
[re: Kayak]
13.06.2006 16:11
|
|
|
Ну не знаю... Я когда возился с этим, возникли какие-то проблемы, решилось прописыванием в httpd.conf. А вообще:
Unbelievably mod_rewrite provides URL manipulations in per-directory context, i.e., within .htaccess files, although these are reached a very long time after the URLs have been translated to filenames. It has to be this way because .htaccess files live in the filesystem, so processing has already reached this stage. In other words: According to the API phases at this time it is too late for any URL manipulations. To overcome this chicken and egg problem mod_rewrite uses a trick: When you manipulate a URL/filename in per-directory context mod_rewrite first rewrites the filename back to its corresponding URL (which is usually impossible, but see the RewriteBase directive below for the trick to achieve this) and then initiates a new internal sub-request with the new URL. This restarts processing of the API phases.
|
Чужой код - потемки (с) |
|