Код: Выделить всё
Redirect 301 /catalog/123/ https://site.com
но редирект идет на адрес https://site.com/?module=ProductsView&category=123&lang_label=
Подскажите как правильно сделать редирект с одной страницы на главную?
Код: Выделить всё
Redirect 301 /catalog/123/ https://site.com
Так и сделал, пробовал делать ниже, выше всех правил сразу после RewriteEngine onOkayCMS писал(а):Поднимите его выше по коду. Поставьте после первых четырех строк.
Код: Выделить всё
# php_flag display_errors on
# php_flag display_startup_errors on
#php_value session.cookie_httponly true
AddDefaultCharset UTF-8
ErrorDocument 404 /404
RewriteEngine on
#RewriteBase /
# Редирект на https
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
# Редирект без www
RewriteCond %{HTTP_HOST} ^www.site\.com$ [NC]
RewriteRule ^(.*)$ https://site.com/$1 [R=301,L]
# Редирект c дублей главной страницы
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(default|index|main)\.(html|php|htm)\ HTTP/ [NC]
RewriteRule ^(([^/]+/)*)(default|main|index)\.(html|php|htm)$ https://site.com/$1 [L,R=301]
# Редирект с повторяющихся слешей
RewriteCond %{REQUEST_URI} ^(.*)/{2,}(.*)$
RewriteRule ^(.*)$ %1/%2 [R=301,L]
# Редирект со слеша в конце на без него
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^(.+)/$ %1 [R=301,L]
# Кэширование / поддерживается не на всех хостингах
<ifModule mod_expires.c>
ExpiresActive On
#по умолчанию кеш на 5 секунд
ExpiresDefault "access plus 1 month"
#кэшируем флэш и изображения на месяц
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType image/jpeg "access plus 4 weeks"
ExpiresByType image/png "access plus 30 days"
ExpiresByType image/gif "access plus 43829 minutes"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
#кэшируем CSS, JavaScript и текстовые файлы на одну неделю
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 604800 seconds"
ExpiresByType application/javascript "access plus 604800 seconds"
ExpiresByType application/x-javascript "access plus 604800 seconds"
#кэшируем HTML и HTM файлы на один день
ExpiresByType text/html "access plus 43200 seconds"
#кэшируем XML файлы на десять минут
ExpiresByType application/xhtml+xml "access plus 600 seconds"
</ifModule>
<IfModule mod_setenvif.c>
BrowserMatch "MSIE" force-no-vary
BrowserMatch "Mozilla/4.[0-9]{2}" force-no-vary
</IfModule>
<ifModule mod_headers.c>
#кэшировать HTML и HTM файлы на один день
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>
#кэшировать CSS, JavaScript и текстовые файлы на одну неделю
<FilesMatch "\.(js|css|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
#кэшировать флэш и изображения на месяц
<FilesMatch "\.(flv|swf|ico|gif|jpg|jpeg|png)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
#отключить кэширование
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control
</FilesMatch>
</IfModule>
<IfModule mod_setenvif.c>
BrowserMatch "MSIE" force-no-vary
BrowserMatch "Mozilla/4.[0-9]{2}" force-no-vary
</IfModule>
# Gzip сжатие / поддерживается не на всех хостингах
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/css
<ifmodule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</ifmodule>
</ifmodule>
# Админка теперь по адресу /backend
RewriteRule ^admin/?$ backend [L]
# Каталог товаров
RewriteRule ^([a-z]{2}/)?catalog/([^/]+)/?$ index.php?module=ProductsView&category=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?catalog/([^/]+) index.php?module=ProductsView&category=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?products/([^/]+)/?$ index.php?module=ProductView&product_url=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?all-products/?$ index.php?module=ProductsView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?all-products/([^/]+) index.php?module=ProductsView&lang_label=$1&page_url=all-products [L,QSA]
RewriteRule ^([a-z]{2}/)?discounted/?$ index.php?module=ProductsView&lang_label=$1&mode=discounted [L,QSA]
RewriteRule ^([a-z]{2}/)?discounted/([^/]+) index.php?module=ProductsView&lang_label=$1&page_url=discounted&mode=discounted [L,QSA]
RewriteRule ^([a-z]{2}/)?bestsellers/?$ index.php?module=ProductsView&lang_label=$1&mode=bestsellers [L,QSA]
RewriteRule ^([a-z]{2}/)?bestsellers/([^/]+) index.php?module=ProductsView&lang_label=$1&page_url=bestsellers&mode=bestsellers [L,QSA]
RewriteRule ^([a-z]{2}/)?brands/?$ index.php?module=BrandsView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?brands/([^/]+) index.php?module=ProductsView&brand=$2&lang_label=$1 [L,QSA]
# Блог
RewriteRule ^([a-z]{2}/)?blog/([^/]+)/?$ index.php?module=BlogView&url=$2&lang_label=$1&type_post=blog [L,QSA]
RewriteRule ^([a-z]{2}/)?blog/?$ index.php?module=BlogView&lang_label=$1&type_post=blog [L,QSA]
# Новости
RewriteRule ^([a-z]{2}/)?news/([^/]+)/?$ index.php?module=BlogView&url=$2&lang_label=$1&type_post=news [L,QSA]
RewriteRule ^([a-z]{2}/)?news/?$ index.php?module=BlogView&lang_label=$1&type_post=news [L,QSA]
# Избранное
RewriteRule ^([a-z]{2}/)?wishlist/?$ index.php?module=WishlistView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?wishlist/([^/]+)/?$ index.php?module=WishlistView&id=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?wishlist/delete/([^/]+)/?$ index.php?module=WishlistView&id=$2&action=delete&lang_label=$1 [L,QSA]
# Сравнение
RewriteRule ^([a-z]{2}/)?comparison/?$ index.php?module=ComparisonView&lang_label=$1 [L,QSA]
# Корзина и заказы
RewriteRule ^([a-z]{2}/)?cart/?$ index.php?module=CartView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?cart/([^/]+)/?$ index.php?module=CartView&add_variant=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?cart/remove/([^/]+)/?$ index.php?module=CartView&delete_variant=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?order/([^/]+)/?$ index.php?module=OrderView&url=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?order/?$ index.php?module=OrderView&lang_label=$1 [L,QSA]
# Для пользователей
RewriteRule ^([a-z]{2}/)?user/login/?$ index.php?module=LoginView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?user/register/?$ index.php?module=RegisterView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?user/logout/?$ index.php?module=LoginView&action=logout&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?user/password_remind/?$ index.php?module=LoginView&action=password_remind&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?user/password_remind/([0-9a-z]+)/?$ index.php?module=LoginView&action=password_remind&code=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?user/?$ index.php?module=UserView&lang_label=$1 [L,QSA]
# Google sitemap
RewriteRule ^([a-z]{2}/)?sitemap\.xml?$ sitemap.php?lang_label=$1 [L,QSA]
# XML
RewriteRule ^feed\.xml?$ feed.php [L,QSA]
# feedback
RewriteRule ^([a-z]{2}/)?contact/?$ index.php?module=FeedbackView&lang_label=$1 [L,QSA]
# reviews
RewriteRule ^([a-z]{2}/)?reviews/?$ index.php?module=ReviewsView&lang_label=$1 [L,QSA]
#downloads
RewriteRule ^([a-z]{2}/)?order/([^/]+)/([^/]+)/?$ index.php?module=OrderView&url=$2&file=$3&lang_label=$1 [L,QSA]
# Статические страницы
RewriteRule ^([a-z]{2}/?)?/?$ index.php?module=MainView&page_url=&lang_label=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]{2}/)?([^/]+)/?$ index.php?lang_label=$1&module=PageView&page_url=$2 [L,QSA]
# Статические страницы
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/?$ index.php?module=PageView&page_url=$1 [L,QSA]
#RewriteRule ^([^/]*)/?$ index.php?module=PageView&page_url=$1 [L,QSA]
#RewriteRule ^/?$ index.php?module=MainView&page_url= [L,QSA]
# Ресайз картинок на лету
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
#resizing_image
RewriteRule ^files/(.+)/(.+) resize/resize.php?object=$1&file=$2&token=%{QUERY_STRING}
##resizing_image
Julius123 писал(а):Так и сделал, пробовал делать ниже, выше всех правил сразу после RewriteEngine onOkayCMS писал(а):Поднимите его выше по коду. Поставьте после первых четырех строк.
Вот полностью сам файлКод: Выделить всё
# php_flag display_errors on
# php_flag display_startup_errors on
#php_value session.cookie_httponly true
AddDefaultCharset UTF-8
ErrorDocument 404 /404
RewriteEngine on
#RewriteBase /
# Редирект на https
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
# Редирект без www
RewriteCond %{HTTP_HOST} ^www.site\.com$ [NC]
RewriteRule ^(.*)$ https://site.com/$1 [R=301,L]
# Редирект c дублей главной страницы
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(default|index|main)\.(html|php|htm)\ HTTP/ [NC]
RewriteRule ^(([^/]+/)*)(default|main|index)\.(html|php|htm)$ https://site.com/$1 [L,R=301]
# Редирект с повторяющихся слешей
RewriteCond %{REQUEST_URI} ^(.*)/{2,}(.*)$
RewriteRule ^(.*)$ %1/%2 [R=301,L]
# Редирект со слеша в конце на без него
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^(.+)/$ %1 [R=301,L]
# Кэширование / поддерживается не на всех хостингах
<ifModule mod_expires.c>
ExpiresActive On
#по умолчанию кеш на 5 секунд
ExpiresDefault "access plus 1 month"
#кэшируем флэш и изображения на месяц
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType image/jpeg "access plus 4 weeks"
ExpiresByType image/png "access plus 30 days"
ExpiresByType image/gif "access plus 43829 minutes"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
#кэшируем CSS, JavaScript и текстовые файлы на одну неделю
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 604800 seconds"
ExpiresByType application/javascript "access plus 604800 seconds"
ExpiresByType application/x-javascript "access plus 604800 seconds"
#кэшируем HTML и HTM файлы на один день
ExpiresByType text/html "access plus 43200 seconds"
#кэшируем XML файлы на десять минут
ExpiresByType application/xhtml+xml "access plus 600 seconds"
</ifModule>
<IfModule mod_setenvif.c>
BrowserMatch "MSIE" force-no-vary
BrowserMatch "Mozilla/4.[0-9]{2}" force-no-vary
</IfModule>
<ifModule mod_headers.c>
#кэшировать HTML и HTM файлы на один день
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>
#кэшировать CSS, JavaScript и текстовые файлы на одну неделю
<FilesMatch "\.(js|css|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
#кэшировать флэш и изображения на месяц
<FilesMatch "\.(flv|swf|ico|gif|jpg|jpeg|png)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
#отключить кэширование
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control
</FilesMatch>
</IfModule>
<IfModule mod_setenvif.c>
BrowserMatch "MSIE" force-no-vary
BrowserMatch "Mozilla/4.[0-9]{2}" force-no-vary
</IfModule>
# Gzip сжатие / поддерживается не на всех хостингах
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/css
<ifmodule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</ifmodule>
</ifmodule>
# Админка теперь по адресу /backend
RewriteRule ^admin/?$ backend [L]
# Каталог товаров
RewriteRule ^([a-z]{2}/)?catalog/([^/]+)/?$ index.php?module=ProductsView&category=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?catalog/([^/]+) index.php?module=ProductsView&category=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?products/([^/]+)/?$ index.php?module=ProductView&product_url=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?all-products/?$ index.php?module=ProductsView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?all-products/([^/]+) index.php?module=ProductsView&lang_label=$1&page_url=all-products [L,QSA]
RewriteRule ^([a-z]{2}/)?discounted/?$ index.php?module=ProductsView&lang_label=$1&mode=discounted [L,QSA]
RewriteRule ^([a-z]{2}/)?discounted/([^/]+) index.php?module=ProductsView&lang_label=$1&page_url=discounted&mode=discounted [L,QSA]
RewriteRule ^([a-z]{2}/)?bestsellers/?$ index.php?module=ProductsView&lang_label=$1&mode=bestsellers [L,QSA]
RewriteRule ^([a-z]{2}/)?bestsellers/([^/]+) index.php?module=ProductsView&lang_label=$1&page_url=bestsellers&mode=bestsellers [L,QSA]
RewriteRule ^([a-z]{2}/)?brands/?$ index.php?module=BrandsView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?brands/([^/]+) index.php?module=ProductsView&brand=$2&lang_label=$1 [L,QSA]
# Блог
RewriteRule ^([a-z]{2}/)?blog/([^/]+)/?$ index.php?module=BlogView&url=$2&lang_label=$1&type_post=blog [L,QSA]
RewriteRule ^([a-z]{2}/)?blog/?$ index.php?module=BlogView&lang_label=$1&type_post=blog [L,QSA]
# Новости
RewriteRule ^([a-z]{2}/)?news/([^/]+)/?$ index.php?module=BlogView&url=$2&lang_label=$1&type_post=news [L,QSA]
RewriteRule ^([a-z]{2}/)?news/?$ index.php?module=BlogView&lang_label=$1&type_post=news [L,QSA]
# Избранное
RewriteRule ^([a-z]{2}/)?wishlist/?$ index.php?module=WishlistView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?wishlist/([^/]+)/?$ index.php?module=WishlistView&id=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?wishlist/delete/([^/]+)/?$ index.php?module=WishlistView&id=$2&action=delete&lang_label=$1 [L,QSA]
# Сравнение
RewriteRule ^([a-z]{2}/)?comparison/?$ index.php?module=ComparisonView&lang_label=$1 [L,QSA]
# Корзина и заказы
RewriteRule ^([a-z]{2}/)?cart/?$ index.php?module=CartView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?cart/([^/]+)/?$ index.php?module=CartView&add_variant=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?cart/remove/([^/]+)/?$ index.php?module=CartView&delete_variant=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?order/([^/]+)/?$ index.php?module=OrderView&url=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?order/?$ index.php?module=OrderView&lang_label=$1 [L,QSA]
# Для пользователей
RewriteRule ^([a-z]{2}/)?user/login/?$ index.php?module=LoginView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?user/register/?$ index.php?module=RegisterView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?user/logout/?$ index.php?module=LoginView&action=logout&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?user/password_remind/?$ index.php?module=LoginView&action=password_remind&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?user/password_remind/([0-9a-z]+)/?$ index.php?module=LoginView&action=password_remind&code=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?user/?$ index.php?module=UserView&lang_label=$1 [L,QSA]
# Google sitemap
RewriteRule ^([a-z]{2}/)?sitemap\.xml?$ sitemap.php?lang_label=$1 [L,QSA]
# XML
RewriteRule ^feed\.xml?$ feed.php [L,QSA]
# feedback
RewriteRule ^([a-z]{2}/)?contact/?$ index.php?module=FeedbackView&lang_label=$1 [L,QSA]
# reviews
RewriteRule ^([a-z]{2}/)?reviews/?$ index.php?module=ReviewsView&lang_label=$1 [L,QSA]
#downloads
RewriteRule ^([a-z]{2}/)?order/([^/]+)/([^/]+)/?$ index.php?module=OrderView&url=$2&file=$3&lang_label=$1 [L,QSA]
# Статические страницы
RewriteRule ^([a-z]{2}/?)?/?$ index.php?module=MainView&page_url=&lang_label=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]{2}/)?([^/]+)/?$ index.php?lang_label=$1&module=PageView&page_url=$2 [L,QSA]
# Статические страницы
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/?$ index.php?module=PageView&page_url=$1 [L,QSA]
#RewriteRule ^([^/]*)/?$ index.php?module=PageView&page_url=$1 [L,QSA]
#RewriteRule ^/?$ index.php?module=MainView&page_url= [L,QSA]
# Ресайз картинок на лету
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
#resizing_image
RewriteRule ^files/(.+)/(.+) resize/resize.php?object=$1&file=$2&token=%{QUERY_STRING}
##resizing_image
Пришлите доступы в тех. поддержку через админ панель сайта, вам сделают редирект.Julius123 писал(а):Да, пробовал на чистой CMS дажеOkayCMS писал(а):И что, после RewriteEngine on всё равно выдает такой редирект?
Код: Выделить всё
RewriteRule ^/files/uploads/catalogues/Catalogue_cryogenic_valves_CCK_Cryonica.pdf$ /brands/feilun? [L,R=301]
Вернуться в «Вопросы по работе с OkayCMS»
Сейчас этот раздел просматривают: 27 гостей