Nginx - Mod_Rewrite

Тема в разделе "Ошибки при работе с Joomla", создана пользователем Ve0, 10.07.2012.

  1. Ve0
    Offline

    Ve0 Недавно здесь

    Регистрация:
    10.07.2012
    Сообщения:
    5
    Симпатии:
    0
    Пол:
    Мужской
    Я знаю, тема обсуждалась тут и в интернете много раз. Но вопрос у меня немного в другом.

    На сервере стоит: NGinx/1.2.1, Apache/2.2.22 (Ubuntu), PHP 5.3.10-1ubuntu3.2
    Соответственно, Nginx отдает статику, Apache обрабатывает скрипты.

    У меня все работает. Но, как в анекдоте, есть нюанс.

    Есть 2 Джумлы. 1.5.25 и 2.5.6. Но обовсем по порядку:

    1. На джумле 1.5 сейчас ссылки вида www.sitename.ru/2012-03-07-12-19-08/2012-03-07-12-45-36.html . Она не работает, но если удалить в конце ссылки .html и поставить просто /, то ссылка прекрассно открывается.

    2. На джумле 2.5 проблемка такого же характера, но ссылка другого вида: http://t.sitename.ru/using-joomla - ссылка никуда не ведет, открывается индекс. Но как только в конце добавляешь /, то ссылка прекрассно работает и открывается нужная страница.

    Подскажите плз куда рыть? Перегуглил много, и ваш форум тоже, но не нашел решения.
     
  2.  
  3. OlegK
    Offline

    OlegK Russian Joomla! Team Команда форума ⇒ Профи ⇐

    Регистрация:
    17.01.2011
    Сообщения:
    7 813
    Симпатии:
    771
    Пол:
    Мужской
    htaccess И какой СЕО стоит,был установлен?
     
  4. Ve0
    Offline

    Ve0 Недавно здесь

    Регистрация:
    10.07.2012
    Сообщения:
    5
    Симпатии:
    0
    Пол:
    Мужской
    htacsess стоит стандартный. что шел в комплекте.
    2.5 стоит ВСЕ по умолчанию, кроме того, что я включил мод реврайт.

    2.5 можно посиотреть тут: http://t.veoserv.ru/ - никакой рекоамы, там чистая, только что установленная Joomla.

    В конфиг Nginx для работоспособности Joomla вставлен код:
    Код (CODE):
    1. try_files $uri $uri/ /index.php?q=$1;


    .htacsess joomla 1.5
    Код (CODE):
    1. root@veo-http:/var/www/pargolovo/http# cat .htaccess
    2. ##
    3. # @version $Id: htaccess.txt 21064 2011-04-03 22:12:19Z dextercowley $
    4. # @package Joomla
    5. # @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
    6. # @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
    7. # Joomla! is Free Software
    8. ##
    9.  
    10.  
    11. #####################################################
    12. #  READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE
    13. #
    14. # The line just below this section: 'Options +FollowSymLinks' may cause problems
    15. # with some server configurations.  It is required for use of mod_rewrite, but may already
    16. # be set by your server administrator in a way that dissallows changing it in
    17. # your .htaccess file.  If using it causes your server to error out, comment it out (add # to
    18. # beginning of line), reload your site in your browser and test your sef url's.  If they work,
    19. # it has been set by your server administrator and you do not need it set here.
    20. #
    21. #####################################################
    22.  
    23. ##  Can be commented out if causes errors, see notes above.
    24. Options +FollowSymLinks
    25.  
    26. #
    27. #  mod_rewrite in use
    28.  
    29. RewriteEngine On
    30.  
    31. ########## Begin - Rewrite rules to block out some common exploits
    32. ## If you experience problems on your site block out the operations listed below
    33. ## This attempts to block the most common type of exploit `attempts` to Joomla!
    34. #
    35. ## Deny access to extension xml files (uncomment out to activate)
    36. #<Files ~ "\.xml$">
    37. #Order allow,deny
    38. #Deny from all
    39. #Satisfy all
    40. #</Files>
    41. ## End of deny access to extension xml files
    42. # Block out any script trying to set a mosConfig value through the URL
    43. RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
    44. # Block out any script trying to base64_encode data within the URL
    45. RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
    46. # Block out any script that includes a <script> tag in URL
    47. RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
    48. # Block out any script trying to set a PHP GLOBALS variable via URL
    49. RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
    50. # Block out any script trying to modify a _REQUEST variable via URL
    51. RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
    52. # Return 403 Forbidden header and show the content of the root homepage
    53. RewriteRule .* index.php [F]
    54. #
    55. ########## End - Rewrite rules to block out some common exploits
    56.  
    57.  
    58. ########## Begin - Custom redirects
    59. #
    60. # If you need to redirect some pages, or set a canonical non-www to
    61. # www redirect (or vice versa), place that code here. Ensure those
    62. # redirects use the correct RewriteRule syntax and the [R=301,L] flags.
    63. #
    64. ########## End - Custom redirects
    65.  
    66.  
    67. #  Uncomment following line if your webserver's URL
    68. #  is not directly related to physical file paths.
    69. #  Update Your Joomla! Directory (just / for root)
    70.  
    71. # RewriteBase /
    72.  
    73.  
    74. ########## Begin - Joomla! core SEF Section
    75. #
    76. RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    77. #
    78. # If the requested path and file is not /index.php and the request
    79. # has not already been internally rewritten to the index.php script
    80. RewriteCond %{REQUEST_URI} !^/index\.php
    81. # and the request is for root, or for an extensionless URL, or the
    82. # requested URL ends with one of the listed extensions
    83. RewriteCond %{REQUEST_URI} (/[^.]*|\.(php|html|feed|pdf|raw))$ [NC]
    84. # and the requested path and file doesn't directly match a physical file
    85. RewriteCond %{REQUEST_FILENAME} !-f
    86. # and the requested path and file doesn't directly match a physical folder
    87. RewriteCond %{REQUEST_FILENAME} !-d
    88. # internally rewrite the request to the index.php script
    89. RewriteRule .* index.php [L]
    90. #
    91. ########## End - Joomla! core SEF Section


    .htacsess joomla 2.5:
    Код (CODE):
    1. root@veo-http:/var/www/veoserv/test# cat .htaccess
    2. ##
    3. # @package      Joomla
    4. # @copyright    Copyright (C) 2005 - 2012 Open Source Matters. All rights reserved.
    5. # @license      GNU General Public License version 2 or later; see LICENSE.txt
    6. ##
    7.  
    8. ##
    9. # READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE!
    10. #
    11. # The line just below this section: 'Options +FollowSymLinks' may cause problems
    12. # with some server configurations.  It is required for use of mod_rewrite, but may already
    13. # be set by your server administrator in a way that dissallows changing it in
    14. # your .htaccess file.  If using it causes your server to error out, comment it out (add # to
    15. # beginning of line), reload your site in your browser and test your sef url's.  If they work,
    16. # it has been set by your server administrator and you do not need it set here.
    17. ##
    18.  
    19. ## Can be commented out if causes errors, see notes above.
    20. Options +FollowSymLinks
    21.  
    22. ## Mod_rewrite in use.
    23.  
    24. RewriteEngine On
    25.  
    26. ## Begin - Rewrite rules to block out some common exploits.
    27. # If you experience problems on your site block out the operations listed below
    28. # This attempts to block the most common type of exploit `attempts` to Joomla!
    29. #
    30. # Block out any script trying to base64_encode data within the URL.
    31. RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
    32. # Block out any script that includes a <script> tag in URL.
    33. RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
    34. # Block out any script trying to set a PHP GLOBALS variable via URL.
    35. RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
    36. # Block out any script trying to modify a _REQUEST variable via URL.
    37. RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
    38. # Return 403 Forbidden header and show the content of the root homepage
    39. RewriteRule .* index.php [F]
    40. #
    41. ## End - Rewrite rules to block out some common exploits.
    42.  
    43. ## Begin - Custom redirects
    44. #
    45. # If you need to redirect some pages, or set a canonical non-www to
    46. # www redirect (or vice versa), place that code here. Ensure those
    47. # redirects use the correct RewriteRule syntax and the [R=301,L] flags.
    48. #
    49. ## End - Custom redirects
    50.  
    51. ##
    52. # Uncomment following line if your webserver's URL
    53. # is not directly related to physical file paths.
    54. # Update Your Joomla! Directory (just / for root).
    55. ##
    56.  
    57. RewriteBase /
    58.  
    59. ## Begin - Joomla! core SEF Section.
    60. #
    61. RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    62. #
    63. # If the requested path and file is not /index.php and the request
    64. # has not already been internally rewritten to the index.php script
    65. RewriteCond %{REQUEST_URI} !^/index\.php
    66. # and the request is for something within the component folder,
    67. # or for the site root, or for an extensionless URL, or the
    68. # requested URL ends with one of the listed extensions
    69. RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
    70. # and the requested path and file doesn't directly match a physical file
    71. RewriteCond %{REQUEST_FILENAME} !-f
    72. # and the requested path and file doesn't directly match a physical folder
    73. RewriteCond %{REQUEST_FILENAME} !-d
    74. # internally rewrite the request to the index.php script
    75. RewriteRule .* index.php [L]
    76. #
    77. ## End - Joomla! core SEF Section.
     
    Последнее редактирование: 10.07.2012
  5. OlegK
    Offline

    OlegK Russian Joomla! Team Команда форума ⇒ Профи ⇐

    Регистрация:
    17.01.2011
    Сообщения:
    7 813
    Симпатии:
    771
    Пол:
    Мужской
    А редирект работает ?
     
  6. Ve0
    Offline

    Ve0 Недавно здесь

    Регистрация:
    10.07.2012
    Сообщения:
    5
    Симпатии:
    0
    Пол:
    Мужской
    редирект куда?

    судя по гуглу и по тому как у меня все устроено, то NGinx не читает файлы .htacsess. Но есть решения, которые приводят к работоспособности данной конструкции.

    я не понимаю как джумла строит ссылки? и если кто нить подскажет как что и куда рыть, то я думаю что я разберусь и выложу решение.
     
  7. Ve0
    Offline

    Ve0 Недавно здесь

    Регистрация:
    10.07.2012
    Сообщения:
    5
    Симпатии:
    0
    Пол:
    Мужской
    коллеги, joomla так и не работает. проблема так и не решена(((
     
  8. OlegK
    Offline

    OlegK Russian Joomla! Team Команда форума ⇒ Профи ⇐

    Регистрация:
    17.01.2011
    Сообщения:
    7 813
    Симпатии:
    771
    Пол:
    Мужской
    ScriptAllias httpd-conf
    Ну и еще добавить на всяк случай ,для чистоты эксперимента в .htaccess
    DirectoryIndex index.php index.html
    и закомментируй строку
     
    Последнее редактирование: 17.07.2012
  9. Ve0
    Offline

    Ve0 Недавно здесь

    Регистрация:
    10.07.2012
    Сообщения:
    5
    Симпатии:
    0
    Пол:
    Мужской
    Спасибо за ответ. Но Вы видимо не в курсе что такое NGinx и никогда не работали с ним. А так же не внимательно читаете мои сообщения.

    Напоминаю, что у меня стоит NGinx, который обрабатывает все запросы, в том числе и ReWrite. Но по странному (а может и не по странному) стечению обстоятельств NGINX НЕ ЧИТАЕТ .htacsess вообще. Т.е. все изменения, которые я делаю в этом файле не обрабатываются воооооообще. Все дириктивы, которые описаны выше, касаются только Апаче, который у меня служит бэкэндом, т.е. обрабатывает ТОЛЬКО php скрипты, т.к. статику отдает NGINX.

    В связи с этим перефразирую вопрос: что нужно прописать в /etc/nginx/nginx.conf или в виртуальных хостах NGINX, чтобы Joomla завелась нормально с ModReWrite?

    Изменения в .htacsess не предлагать, изменения в дириктивах Апача тоже не предлагать, т.к. все это не применяется.

    PS: если апачу полностью передать все, без NGINX, то все работает. Но мне такое не нравится и не устраивает.
     
  10. vomitting
    Offline

    vomitting Недавно здесь

    Регистрация:
    16.08.2010
    Сообщения:
    15
    Симпатии:
    0
    Пол:
    Мужской
    Попробуйте в nginx.conf прописать

    Код (CODE):
    1. location / {
    2.   if (!-f $request_filename) {
    3.     rewrite ^(.*)$ /index.php;
    4.   }
    5. }
     

Поделиться этой страницей

Загрузка...