Legosp Forum
Shop-Script "Legosp" => Разработка => Тема начата: Danilevsky от Марта 29, 2012, 06:46:42 pm
-
Хочу внести вклад в развите LEGO.
Итак, была проблема в некоторых серверах статистики, в т.ч. в поиске яши, были страницы сайта с флешем в конце и без него. Так вот, если слеша нет, то редирект идёт на 404. Естественно ЧПУ включён.
Например, http://lego-demo.shop-script.org/catalog/sotovaya-svyaz/
и http://lego-demo.shop-script.org/catalog/sotovaya-svyaz
Решается добавлением такого текста в ваш .htaccess файл ПЕРЕД другими условиями для rewrite
# Добавляем слеш в конце строки uri
# исключаем файлы
RewriteCond %{REQUEST_FILENAME} !-f
# исключаем символьные ссылки
RewriteCond %{REQUEST_FILENAME} !-l
# исключаем файлы index.php
RewriteCond %{REQUEST_URI} !index.php
# исключаем uri содержащие точки, для пропуска ссылок на файлы
RewriteCond %{REQUEST_URI} !\.[^./]+$
# исключаем uri со слешем на конце
RewriteCond %{REQUEST_URI} !(.*)/$
# 301 перенаправление на запрос со слешем в конце
RewriteRule ^(.*)$ $1/ [R=301,L]
Первоисточник здесь http://drupalblog.ru/blog/auto-adding-trailing-slash-or-hiding-address
Если где-то неправ - поправьте меня.
-
У меня подобное сделано на PHP + если в url присутствует верхний регистр возвращаем "404"
if((!isset($_GET['searchstring'])) and ($_SERVER['REQUEST_METHOD']=="GET"))
{
$reqUrl=$_SERVER['REQUEST_URI'];
$reqUriLen=strlen($reqUrl);
$lasSymb = $reqUrl[$reqUriLen-1];
if (preg_match("/[^a-z,0-9,\/,\-,\_]/", $reqUrl))
{ header("HTTP/1.0 404 Not Found");
header("location: /404/");
exit; }
if($lasSymb!="/"){ header("HTTP/1.1 301 Moved Permanently"); header("location: $reqUrl/");
exit;
}
}
-
в lego 6.1 при таком методе перестает удаляться товар из корзины. Решил так:
RewriteRule ^category/([^/]+)$ http://%{HTTP_HOST}/category/$1/ [R=301,L,QSA]
RewriteRule ^product/([^/]+)$ http://%{HTTP_HOST}/product/$1/ [R=301,L,QSA]
-
можно было и так:
RewriteRule cart/&remove=(.*)/$ index.php?shopping_cart=yes&remove=$1 [L]
RewriteRule cart/&clear/$ index.php?shopping_cart=yes&clear_cart=yes [L]
-
В Lego 5.0.2 ЧПУ вкл. прописал
# Добавляем слеш в конце строки uri
# исключаем файлы
RewriteCond %{REQUEST_FILENAME} !-f
# исключаем символьные ссылки
RewriteCond %{REQUEST_FILENAME} !-l
# исключаем файлы index.php
RewriteCond %{REQUEST_URI} !index.php
# исключаем uri содержащие точки, для пропуска ссылок на файлы
RewriteCond %{REQUEST_URI} !\.[^./]+$
# исключаем uri со слешем на конце
RewriteCond %{REQUEST_URI} !(.*)/$
# 301 перенаправление на запрос со слешем в конце
RewriteRule ^(.*)$ $1/ [R=301,L]
RewriteRule cart/&remove=(.*)/$ index.php?shopping_cart=yes&remove=$1 [L]
RewriteRule cart/&clear/$ index.php?shopping_cart=yes&clear_cart=yes [L]
слеш добавляется, с корзиной все норм,
перестала работать переадресация при входе в админку www.сайт.ru/admin
Подскажите где поправить?
на всякий случай весь .htaccess
[spoiler]#config
DirectoryIndex index.php
AddDefaultCharset windows-1251
AddCharset windows-1251 .php
Options -Indexes
# кеширование в браузере на стороне пользователя
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access 7 days"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
ExpiresByType text/css "access plus 1 year"
ExpiresByType text/html "access plus 7 day"
ExpiresByType text/x-javascript "access 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType application/x-shockwave-flash "access 1 year"
</IfModule>
# Cache-Control
<ifModule mod_headers.c>
# 30 дней
<filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
# 30 дней
<filesMatch "\.(css|js)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
# 2 дня
<filesMatch "\.(xml|txt)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
</filesMatch>
# 1 день
<filesMatch "\.(html|htm|php)$">
Header set Cache-Control "max-age=172800, private, must-revalidate"
</filesMatch>
</ifModule>
# Добавляем слеш в конце строки uri
# исключаем файлы
RewriteCond %{REQUEST_FILENAME} !-f
# исключаем символьные ссылки
RewriteCond %{REQUEST_FILENAME} !-l
# исключаем файлы index.php
RewriteCond %{REQUEST_URI} !index.php
# исключаем uri содержащие точки, для пропуска ссылок на файлы
RewriteCond %{REQUEST_URI} !\.[^./]+$
# исключаем uri со слешем на конце
RewriteCond %{REQUEST_URI} !(.*)/$
# 301 перенаправление на запрос со слешем в конце
RewriteRule ^(.*)$ $1/ [R=301,L]
RewriteRule cart/&remove=(.*)/$ index.php?shopping_cart=yes&remove=$1 [L]
RewriteRule cart/&clear/$ index.php?shopping_cart=yes&clear_cart=yes [L]
#rewrite url's
RewriteEngine On
RewriteBase /
#www redirect
RewriteCond %{HTTP_HOST} ^www.my.ru$ [NC]
RewriteRule ^(.*)$ http://my.ru/$1 [R=301,L]
#copress js and css
RewriteRule core/js/(.*)\.js$ core/jscss.php [L]
RewriteRule css/(.*).css$ core/jscss.php [L]
#payment
RewriteRule payment/$ index.php?payment [L]
#about url's
RewriteRule ^catalog/(.*)/about/$ index.php?about&category=$1/ [L]
RewriteRule ^brand/(.*)/about/$ index.php?about&brands=$1/ [L]
#catalog url's
RewriteRule ^catalog/(.*)$ index.php?catalog_hurl=$1 [L]
RewriteRule ^product/(.*)$ index.php?product_hurl=$1 [L]
RewriteRule ^news/(.*)$ index.php?news&news=$1 [L]
RewriteRule ^pages/(.*)$ index.php?pages&pages=$1 [L]
RewriteRule ^tags/(.*)$ index.php?tags_hurl=$1 [L]
RewriteRule ^brand/(.*)/(.*) index.php?brand=$1/$2 [L]
#sort url's
RewriteRule (.*)/(.*)/&sort=(.*)&order=(.*)$ index.php?$1_hurl=$2&sort=$3&order=$4 [L]
#offset url's
#RewriteRule offset/(.*)/&sort=(.*)&order=(.*)$ index.php?searchstring=$1&sort=$2&order=$3 [L]
RewriteRule (.*)/(.*)/&offset=(.*)$ index.php?$1_hurl=$2&offset=$3 [L]
RewriteRule (.*)/(.*)/&show_all=yes$ index.php?$1_hurl=$2&show_all=yes [L]
#lang url's
RewriteRule ru/$ index.php?new_language=0 [L]
RewriteRule en/$ index.php?new_language=1 [L]
#information url's
RewriteRule info/(.*)$ index.php?aux_pages=$1 [L]
RewriteRule contact/&send_result=(.*)$ index.php?contact&send_result=$1 [L]
RewriteRule contact/$ index.php?contact [L]
RewriteRule service/$ index.php?aux_page=aux2 [L]
RewriteRule pricelist/([0-9]*)/$ index.php?show_price=$1 [L]
RewriteRule pricelist/$ index.php?show_price=yes [L]
RewriteRule ^price.xls$ core/core_xls.php [L]
RewriteRule feed.xml$ core/core_rss.php [L]
RewriteRule ^about/$ index.php?aux_page=aux1 [L]
RewriteRule grafik/$ index.php?aux_page=aux1 [L]
RewriteRule adress/$ index.php?aux_page=aux1 [L]
RewriteRule sitemap\.xml$ core/sitemap.php [L]
RewriteRule sitemap/$ index.php?sitemap [L]
#administration url's
RewriteRule admin$ admin.php [L]
RewriteRule admin/$ admin.php [L]
#cart url's
RewriteRule add2cart/(.*)$ index.php?shopping_cart&add2cart=$1 [L]
RewriteRule cart/$ index.php?shopping_cart=yes [L]
RewriteRule cart/&remove=(.*)$ index.php?shopping_cart=yes&remove=$1 [L]
RewriteRule cart/&clear$ index.php?shopping_cart=yes&clear_cart=yes [L]
RewriteRule cart/order/$ index.php?order_custinfo=yes [L]
RewriteRule cart/order_placed/$ index.php?order_placement_result=1 [L]
RewriteRule printorder/$ core/core_printorder.php [L]
RewriteRule pd4/$ core/print_pd4.php [L]
#yandex url's
RewriteRule yandex\.(xml|yml)$ core/core_yml.php [L]
RewriteRule metamarket\.xml$ core/core_metamarket.php [L]
#search_expanded url's
RewriteRule search_expanded/ index.php?search_expanded=1 [L]
#watermark
#RewriteRule ^(products_pictures|products_thumb|userfiles)/(.*\.(gif|jpg|jpeg|png)) core/watermark.php?dir=$1&img_path=$2 [L] # All image
#RewriteRule ^(products_pictures)/(.*\.(gif|jpg|jpeg|png)) core/watermark.php?dir=$1&img_path=$2 [L] # All products_pictures
#RewriteRule ^(products_pictures)/(.*-B\.(gif|jpg|jpeg|png)) core/watermark.php?dir=$1&img_path=$2 [L] # only big products_pictures
#RewriteRule ^(products_pictures)/(.*-H\.(gif|jpg|jpeg|png)) core/watermark.php?dir=$1&img_path=$2 [L] # only smal products_pictures
#RewriteRule ^(products_thumb)/(.*\.(gif|jpg|jpeg|png)) core/watermark.php?dir=$1&img_path=$2 [L] # All products_thumb
#errors
RewriteRule 404/$ index.php?error_404 [L]
RewriteRule 404/$ core/core_404.php [L]
[/spoiler]
-
хотелось бы htaccess полностью увидеть
-
можно было и так:
RewriteRule cart/&remove=(.*)/$ index.php?shopping_cart=yes&remove=$1 [L]
RewriteRule cart/&clear/$ index.php?shopping_cart=yes&clear_cart=yes [L]
Да, такой вариант более приемлем. Спасибо.
-
ой. не увидел). извините.
-
А если так? Только домен свой в склейке, если она нужна.
<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>
#config
DirectoryIndex index.php
AddDefaultCharset windows-1251
AddCharset windows-1251 .php
Options -Indexes
#rewrite url's
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_URI} !\.[^./]+$
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ $1/ [R=301,L]
RewriteRule cart/&remove=(.*)/$ index.php?shopping_cart=yes&remove=$1 [L]
RewriteRule cart/&clear/$ index.php?shopping_cart=yes&clear_cart=yes [L]
#www redirect
RewriteCond %{HTTP_HOST} ^www.club-mebel.ru$ [NC]
RewriteRule ^(.*)$ http://club-mebel.ru/$1 [R=301,L]
#copress js and css
RewriteRule core/js/(.*)\.js$ core/jscss.php [L]
RewriteRule css/css_(.*)/(.*).css$ core/jscss.php [L]
RewriteRule ^core_ajaxconst.js$ core/core_ajaxconst.php [L]
#payment
RewriteRule payment/$ index.php?payment [L]
#about url's
RewriteRule ^catalog/(.*)/about/$ index.php?about&category=$1/ [L]
RewriteRule ^brand/(.*)/about/$ index.php?about&brands=$1/ [L]
#catalog url's
RewriteRule ^catalog/(.*)$ index.php?catalog_hurl=$1 [L]
RewriteRule ^product/(.*)$ index.php?product_hurl=$1 [L]
RewriteRule ^news/(.*)$ index.php?news&news=$1 [L]
RewriteRule ^pages/(.*)$ index.php?pages&pages=$1 [L]
RewriteRule ^tags/(.*)$ index.php?tags_hurl=$1 [L]
RewriteRule ^brand/(.*)/(.*) index.php?brand=$1/$2 [L]
#sort url's
RewriteRule (.*)/(.*)/&sort=(.*)&order=(.*)$ index.php?$1_hurl=$2&sort=$3&order=$4 [L]
#offset url's
#RewriteRule offset/(.*)/&sort=(.*)&order=(.*)$ index.php?searchstring=$1&sort=$2&order=$3 [L]
RewriteRule (.*)/(.*)/&offset=(.*)$ index.php?$1_hurl=$2&offset=$3 [L]
RewriteRule (.*)/(.*)/&show_all=yes$ index.php?$1_hurl=$2&show_all=yes [L]
#lang url's
RewriteRule ru/$ index.php?new_language=0 [L]
RewriteRule en/$ index.php?new_language=1 [L]
#information url's
RewriteRule info/(.*)$ index.php?aux_pages=$1 [L]
RewriteRule contact/&send_result=(.*)$ index.php?contact&send_result=$1 [L]
RewriteRule contact/$ index.php?contact [L]
RewriteRule service/$ index.php?aux_page=aux2 [L]
RewriteRule pricelist/([0-9]*)/$ index.php?show_price=$1 [L]
RewriteRule pricelist/$ index.php?show_price=yes [L]
RewriteRule ^price.xls$ core/core_xls.php [L]
RewriteRule feed.xml$ core/core_rss.php [L]
RewriteRule ^about/$ index.php?aux_page=aux1 [L]
RewriteRule grafik/$ index.php?aux_page=aux1 [L]
RewriteRule adress/$ index.php?aux_page=aux1 [L]
RewriteRule sitemap\.xml$ core/sitemap.php [L]
RewriteRule sitemap/$ index.php?sitemap [L]
#administration url's
RewriteRule admin$ admin.php [L]
RewriteRule admin/$ admin.php [L]
#cart url's
RewriteRule add2cart/(.*)$ index.php?shopping_cart&add2cart=$1 [L]
RewriteRule cart/$ index.php?shopping_cart=yes [L]
RewriteRule cart/&remove=(.*)$ index.php?shopping_cart=yes&remove=$1 [L]
RewriteRule cart/&clear$ index.php?shopping_cart=yes&clear_cart=yes [L]
RewriteRule cart/order/$ index.php?order_custinfo=yes [L]
RewriteRule cart/order_placed/$ index.php?order_placement_result=1 [L]
RewriteRule printorder/$ core/core_printorder.php [L]
RewriteRule pd4/$ core/print_pd4.php [L]
#yandex url's
RewriteRule yandex\.(xml|yml)$ core/core_yml.php [L]
RewriteRule metamarket\.xml$ core/core_metamarket.php [L]
#search_expanded url's
RewriteRule search_expanded/ index.php?search_expanded=1 [L]
#watermark
#RewriteRule ^(products_pictures|products_thumb|userfiles)/(.*\.(gif|jpg|jpeg|png)) core/watermark.php?dir=$1&img_path=$2 [L] # All image
RewriteRule ^(products_pictures)/(.*\.(gif|jpg|jpeg|png)) core/watermark.php?dir=$1&img_path=$2 [L] # All products_pictures
#RewriteRule ^(products_pictures)/(.*-B\.(gif|jpg|jpeg|png)) core/watermark.php?dir=$1&img_path=$2 [L] # only big products_pictures
#RewriteRule ^(products_pictures)/(.*-H\.(gif|jpg|jpeg|png)) core/watermark.php?dir=$1&img_path=$2 [L] # only smal products_pictures
RewriteRule ^(products_thumb)/(.*\.(gif|jpg|jpeg|png)) core/watermark.php?dir=$1&img_path=$2 [L] # All products_thumb
#errors
RewriteRule 404/$ core/core_404.php [L]
ErrorDocument 403 http://club-mebel.ru/404/
ErrorDocument 404 http://club-mebel.ru/404/
# кеширование в браузере на стороне пользователя
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access 7 days"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
ExpiresByType text/css "access plus 1 year"
ExpiresByType text/html "access plus 7 day"
ExpiresByType text/x-javascript "access 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType application/x-shockwave-flash "access 1 year"
</IfModule>
# Cache-Control
<ifModule mod_headers.c>
# 30 дней
<filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
# 30 дней
<filesMatch "\.(css|js)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
# 2 дня
<filesMatch "\.(xml|txt)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
</filesMatch>
# 1 день
<filesMatch "\.(html|htm|php)$">
Header set Cache-Control "max-age=172800, private, must-revalidate"
</filesMatch>
</ifModule>
-
Make me smile все прописал, набираю sayt.ru/admin выдает 404 страницу. Вход в админку работает только по прямой ссылке http://sayt.ru/access_admin.php
-
RewriteRule admin/$ access_admin.php [L] попробуй
-
бах. сам на грабли наткнулся. После этих манипуляций перестали отображаться товары в ссылках типа:
http://club-mebel.ru/catalog/stenki/&offset=10/
Кто подскажет как разрешить. Редактирование htaccess не прокатывает))
-
решил проблему путем смены урла категории и RewriteRule, т.к страницы уже попали в индекс.
-
Остается глобальная пробелма совсеми переменными(сортировка и т.п.)
лечится добавлением
RewriteCond %{REQUEST_URI} !&*