я следующие правила HTAccess в одном из сайтов я работаю:Изменение Htaccess перенаправить страницу своего мобильного эквивалента
# -------------------
# Custom PHP Settings
# -------------------
php_value include_path ".:/var/www/www.example.com/htdocs/custom/lib:/var/www/www.example.com/htdocs/common/lib:/usr/local/lib/php"
# As long as the lib/ directory is in the include_path, these files will always be found
php_value auto_prepend_file common.header.php
php_value auto_append_file common.footer.php
php_value upload_max_filesize "50M"
php_value post_max_size "60M"
# -------------
# Rewrite Rules
# -------------
RewriteEngine On
RewriteBase /
SetEnv SITE_ROOT /var/www/www.example.com/htdocs
# special case for home dir (since it's outside of the RewriteBase)
RewriteRule ^/var/www/www.example.com/htdocs$ // [R,L]
# pretty urls for detail pages
RewriteRule ^(.*)/~.+/(.*)/.*$ $1?id=$2 [L]
# webdav
RewriteRule ^webdav(/?.*)$ shared/webdav.php?p=$1 [L]
RewriteRule ^webdav_file(/?.*)$ shared/webdav_file.php?p=$1 [L]
#images-cache by id
RewriteCond %{QUERY_STRING} ^.*(id=.*)$
RewriteCond %{LA-F:ENV:SITE_ROOT}/content/cache/images/%1 -f
RewriteRule ^.*/?images/display.php content/cache/images/%1 [L]
#images-cache by folder+name
RewriteCond %{LA-F:ENV:SITE_ROOT}/content/cache/images/$2 -f
RewriteRule ^(.*)/?images/(.*) content/cache/images/$2 [L]
#style-cache
RewriteCond %{LA-F:ENV:SITE_ROOT}/content/cache/style/$2 -f
RewriteRule ^(.*)/?style/(.*) content/cache/style/$2 [L]
#fix pdf index pages
RewriteRule ^(.*)/.pdf$ $1/index.pdf [R,L,QSA]
RewriteRule ^.pdf$ index.pdf [R,L,QSA]
#pdf-cache by folder+name
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteCond %{LA-F:ENV:SITE_ROOT}/content/cache/PDF/$1%1 -f
RewriteRule ^(.*).pdf content/cache/PDF/$1%1 [L]
#pdf-cache by folder+name
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{LA-F:ENV:SITE_ROOT}/content/cache/PDF/$1 -f
RewriteRule ^(.*).pdf content/cache/PDF/$1 [L]
# If the file is a directory without the trailing slash, add the slash and
RewriteCond %{LA-F:ENV:SITE_ROOT}/custom/$1 -d
RewriteRule ^(.+[^/])$ $1/ [R,L]
RewriteCond %{LA-F:ENV:SITE_ROOT}/common/$1 -d
RewriteRule ^(.+[^/])$ $1/ [R,L]
# First look for the specified file in the exact location specified. (for internal rewrites)
RewriteCond %{LA-F:ENV:SITE_ROOT}/$1 -f
RewriteRule ^(.*)$ - [L]
# Look for admin logo in config dir before anywhere else
RewriteCond %{LA-F:ENV:SITE_ROOT}/config/clientlogo_$1.$2 -f
RewriteRule ^themes/(.*)/images/hdr_clientlogo.(gif|jpg|jpeg)$ config/clientlogo_$1.$2 [L]
# look for the specified file in custom and common
RewriteCond %{LA-F:ENV:SITE_ROOT}/custom/$1 -f
RewriteRule ^(.*)$ custom/$1 [L]
RewriteCond %{LA-F:ENV:SITE_ROOT}/common/$1 -f
RewriteRule ^(.*)$ common/$1 [L]
# look in the non-versioned content dir
RewriteCond %{LA-F:ENV:SITE_ROOT}/content/$1 -f
RewriteRule ^(.*)$ content/$1 [L]
# this is for index pages (since the last rule will break auto-index files)
RewriteCond %{LA-F:ENV:SITE_ROOT}/custom/$1/index.php -f
RewriteRule ^(.*)/$ custom/$1/index.php [L]
RewriteCond %{LA-F:ENV:SITE_ROOT}/common/$1/index.php -f
RewriteRule ^(.*)/$ common/$1/index.php [L]
# index.html
RewriteCond %{LA-F:ENV:SITE_ROOT}/custom/$1/index.html -f
RewriteRule ^(.*)/$ custom/$1/index.html [L]
RewriteCond %{LA-F:ENV:SITE_ROOT}/common/$1/index.html -f
RewriteRule ^(.*)/$ common/$1/index.html [L]
# special case for root index file
RewriteCond %{LA-F:ENV:SITE_ROOT}/custom/index.php -f
RewriteRule ^$ custom/index.php [L]
RewriteCond %{LA-F:ENV:SITE_ROOT}/common/index.php -f
RewriteRule ^$ common/index.php [L]
# Try stripping off everything but the section (the first directory)
RewriteCond %{LA-F:ENV:SITE_ROOT}/custom/$1/$2 -f
RewriteRule ^([a-zA-Z0-9_]+)/.*/(.*)$ custom/$1/$2 [L]
RewriteCond %{LA-F:ENV:SITE_ROOT}/common/$1/$2 -f
RewriteRule ^([a-zA-Z0-9_]+)/.*/(.*)$ common/$1/$2 [L]
# If we haven't found it yet, look in the shared directory for the file.
RewriteCond %{LA-F:ENV:SITE_ROOT}/custom/shared/$1 -f
RewriteRule ([^/]+)$ custom/shared/$1 [L]
RewriteCond %{LA-F:ENV:SITE_ROOT}/common/shared/$1 -f
RewriteRule ([^/]+)$ common/shared/$1 [L]
# Rewrite Image Directory >-------------------------------------------------
# If the file still has not been found, look in the global images/ directory
# (if the path has images/ in it
RewriteCond %{LA-F:ENV:SITE_ROOT}/custom/images/$2 -f
RewriteRule ^(.*)/?images/(.*) custom/images/$2 [L]
RewriteCond %{LA-F:ENV:SITE_ROOT}/common/images/$2 -f
RewriteRule ^(.*)/?images/(.*) common/images/$2 [L]
# Rewrite rule for image library
RewriteRule ^(.*)/?images/(.*) common/images/display.php?filename=$2 [L,QSA]
RewriteCond %{REQUEST_URI} .pdf
RewriteRule ^(.*).pdf$ common/shared/make.pdf.php [L,QSA]
# Stylesheets in custom/common
RewriteCond %{LA-F:ENV:SITE_ROOT}/custom/style/$2 -f
RewriteRule ^(.*)/style/(.*) custom/style/$2 [L]
RewriteCond %{LA-F:ENV:SITE_ROOT}/common/style/$2 -f
RewriteRule ^(.*)/style/(.*) common/style/$2 [L]
# Dynamic stylesheets >-----------------------------------------------------
RewriteCond %{LA-F:ENV:SITE_ROOT}/custom/style/display.php -f
RewriteRule style/(.*) custom/style/display.php [L]
RewriteRule style/(.*) common/style/display.php [L]
# Javascript in custom/common
RewriteCond %{LA-F:ENV:SITE_ROOT}/custom/js/$2 -f
RewriteRule ^(.*)/js/(.*) custom/js/$2 [L]
RewriteCond %{LA-F:ENV:SITE_ROOT}/common/js/$2 -f
RewriteRule ^(.*)/js/(.*) common/js/$2 [L]
# Rewrite for old URLs and other domains >----------------------------------
# CMS Dynamic pages >-------------------------------------------------------
#mobile
RewriteCond %{REQUEST_URI} !^/mobile/
RewriteCond %{REQUEST_URI} !(.*)\.(.*){2,4}
RewriteCond %{HTTP_USER_AGENT} !^.*ipad.*$ [NC]
RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "sony|symbian|nokia|samsung|mobile|windows ce|epoc|opera mini|nitro|j2me|midp-|cldc-|netfront|mot|up\.browser|up\.link|audiovox" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "blackberry|ericsson,|panasonic|philips|sanyo|sharp|sie-|portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "smartphone|rover|ipaq|au-mic,|alcatel|ericy|vodafone\/|wap1\.|wap2\.|iPhone|android.+mobile" [NC]
RewriteRule (.*)$ http://www.example.com/mobile/ [R,L,QSA]
# Send everything else to shared/content.php for further processing
RewriteCond %{LA-F:ENV:SITE_ROOT}/custom/shared/content.php -f
RewriteRule ^(.*)$ custom/shared/content.php [L]
RewriteRule ^(.*)$ common/shared/content.php [L]
Существует страница на моем сайте, скажем: http://example.com/articles/detail/News/my-article, который работает отлично работает на рабочем столе; однако при просмотре на мобильном устройстве он перенаправляется на домашнюю страницу для мобильных устройств. Мне нравится, что этот URL-адрес будет перенаправлен на его мобильную версию, что похоже на http://example.com/mobile/news/news_detail?id=123.
Есть ли способ, которым я могу определить это в приведенных выше правилах htaccess (только для этого конкретного URL-адреса) для перенаправления на мобильную версию, если их просматривать на мобильных устройствах?
Спасибо
перенаправляет на главную страницу, потому что вы сказали ему сделать это. Если вы хотите исключить страницу, вам нужно добавить ее как условие для ее исключения, а затем перенаправить эту конкретную страницу самостоятельно, используя другое правило. –
@PanamaJack Можете ли вы привести пример, пожалуйста? – farjam