2015-06-25 5 views
1

У меня есть сайт Wordpress на сервере Rackspace Cloud Sites, и в настоящее время у меня есть URL-адрес url и admin, установленный для версии сайта https. Кроме того, у меня есть следующая настройка кода в файле htaccess, чтобы перенаправить все страницы на https.Wordpress (на сервере Rackspace) заставляет весь сайт за SSL за исключением одной страницы

RewriteEngine On 
RewriteBase/
#Force SSL on entire site 
RewriteCond %{ENV:HTTPS} !on [NC] 
RewriteRule ^(.*)$ https://frla.org/$1 [R=301,L] 

Этот код работает, но теперь мне нужно на одну страницу (/example-page) для перенаправления на http URL, потому что мы должны включить встраивать код с третьей стороны, которая не имеет в https версию сайта. Я попробовал следующий код, но он просто перенаправляется на главную страницу сайта.

RewriteCond %{ENV:HTTPS} !on [NC] 
RewriteCond %{REQUEST_URI} !^\/example-page\/ 
RewriteCond %{REQUEST_URI} !^\/example-page\/ 
RewriteRule ^(.*)$ https://frla.org/$1 [R=301,L] 

RewriteCond %{ENV:HTTPS} on [NC] 
RewriteCond %{REQUEST_URI} \/example-page\/ [OR] 
RewriteCond %{REQUEST_URI} \/example-page\/ 
RewriteRule ^(.*)$ http://frla.org/$1 [R=301,L] 

Я думаю, что это что-то делать с тем, что основной параметр Wordpress URL установлен на https. Я ценю любую помощь, которую вы можете мне дать.

Panama Jack, Это мой полный файл htaccess после того, как вы попробовали то, что предложили. Я получаю бесконечную ошибку цикла для всего сайта. Среднее дно этого документа - это все перенаправления, которые мы должны были установить для старых страниц, чтобы направить их на новые страницы, просто fyi.

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
#Force SSL on entire site 
#RewriteCond %{ENV:HTTPS} !on [NC] 
#RewriteRule ^(.*)$ https://frla.org/$1 [R=301,L] 

RewriteCond %{HTTPS} !^on 
RewriteRule ^((?!bill-tracker/?$).*)$ https://frla.org/$1 [R=301,L] 

RewriteCond %{HTTPS} ^on 
RewriteRule ^(bill-tracker/?)$ http://frla.org/$1 [R=301,L] 


#Redirect Specific Pages 
RedirectMatch 301 /frla-news/item/1477-2015-florida-minimum-wage-announced https://www.frla.org/news-release/frla-endorses-governor-rick-scott-for-november-2014-election/ 

RedirectMatch 301 /membership/membership-directory/map https://www.frla.org/member-directory/ 

RedirectMatch 301 /calendar/flat https://www.frla.org/events/ 

RedirectMatch 301 /membership-form https://www.frla.org/membership/join 

RedirectMatch 301 /about/4-training-certification https://www.frla.org/government-relations 

Redirect 301 /faq https://www.frla.org/about/faqs 

Redirect 301 /endless-summer-music-series-and-events https://www.frla.org/endless-summer-music-series-events/ 

RedirectMatch 301 /frla-news/item/551-tip-outs-and-tip-pooling https://www.frla.org/news-release/tip-outs-and-tip-pooling 

RedirectMatch 301 /about/item/127-ceo-profile-carol-dover https://www.frla.org/leadership/ 

RedirectMatch 301 /educational-foundation/item/198-prostart-school-to-career-program https://www.frla.org/educational-foundation/prostart/ 

RedirectMatch 301 /frla-news/item/1491-chef-emeril-lagasse-highlights-special-occasion-restaurants-in-florida-on-national-tv https://www.frla.org/news-release/chef-emeril-lagasse-highlights-special-occasion-restaurants-in-florida-on-national-tv-2/ 

RedirectMatch 301 /frla-news/item/1501-hundreds-of-florida-high-school-students-showcase-culinary-arts-and-restaurant-management-skills-at-statewide-competition https://www.frla.org/news-release/hundreds-of-florida-high-school-students-showcase-culinary-arts-and-restaurant-management-skills-at-statewide-competition/ 

RedirectMatch 301 /frla-news/item/1502-chef-emeril-lagasse-tours-downtown-restaurants-in-the-sunshine-state-on-latest-episode-of-emerils-florida https://www.frla.org/news-release/chef-emeril-lagasse-tours-downtown-restaurants-in-the-sunshine-state-on-latest-episode-of-emerils-florida-2/ 

RedirectMatch 301 /frla-news/item/1500-frlas-broward-chapter-raises-funds-to-support-hospitality-education-for-local-high-school-students https://www.frla.org/frla-news/item/1500-frlas-broward-chapter-raises-funds-to-support-hospitality-education-for-local-high-school-students 

RedirectMatch 301 /frla-news/item/1498-florida-restaurant-and-lodging-associations-pinellas-chapter-installs-new-officers-and-board-of-directors-for-2015 https://www.frla.org/news-release/64863/ 

RedirectMatch 301 /frla-news/item/1503-panama-city-beach-businesses-community-leaders-and-law-enforcement-prepare-for-safe-and-successful-spring-break-at-hospitality-workshop https://www.frla.org/news-release/panama-city-beach-businesses-community-leaders-and-law-enforcement-prepare-for-safe-and-successful-spring-break-at-hospitality-workshop-2/ 

RedirectMatch 301 /frla-news/item/1505-rep-harrison-and-sen-abruzzo-file-bill-to-spur-economic-development https://www.frla.org/news-release/rep-harrison-and-sen-abruzzo-file-bill-to-spur-economic-development/ 

RedirectMatch 301 /frla-news/item/1410-chef-emeril-lagasse-visits-central-florida-farm-to-table-restaurant-and-egg-farm-in-latest-emerils-florida-television-episode- https://www.frla.org/news-release/chef-emeril-lagasse-visits-central-florida-farm-to-table-restaurant-and-egg-farm-in-latest-emerils-florida-television-episode/ 

RedirectMatch 301 /frla-news/item/1420-chef-emeril-lagasse-samples-restaurants-in-south-walton-county-on-latest-emerils-florida-tv-episode https://www.frla.org/news-release/chef-emeril-lagasse-samples-restaurants-in-south-walton-county-on-latest-emerils-florida-tv-episode/ 

RedirectMatch 301 /images/2014_Florida_Tourism_Day_Registration_Form.pdf https://www.frla.org/wp-content/uploads/2015/05/2014_Florida_Tourism_Day_Registration_Form.pdf 

RedirectMatch 301 /frla-news/item/1433-gov-scott-another-record-year-for-florida-tourism https://www.frla.org/news-release/gov-scott-another-record-year-for-florida-tourism/ 

RedirectMatch 301 /frla-news/item/1434-frla-members-donate-reusable-inventory-to-the-florida-department-of-corrections https://www.frla.org/news-release/frla-members-donate-reusable-inventory-to-the-florida-department-of-corrections/ 

RedirectMatch 301 /images/stories/GR/FRLA_2014_Legislative_Scorecard.pdf https://www.frla.org/wp-content/uploads/2015/05/FRLA_2014_Legislative_Scorecard.pdf 

RedirectMatch 301 /events/board-meetings https://www.frla.org/board-meetings/ 

RedirectMatch 301 /frla-news/item/1464-food-network-and-travel-channel-personalities-to-headline-florida-restaurant-and-lodging-associations-marketingoperations-summit https://www.frla.org/news-release/food-network-and-travel-channel-personalities-to-headline-florida-restaurant-and-lodging-associations-marketingoperations-summit/ 

RedirectMatch 301 /frla-news/item/1466--state-implements-new-food-service-inspection-frequency https://www.frla.org/news-release/state-implements-new-food-service-inspection-frequency/ 

RedirectMatch 301 /frla-news/item/1467-the-florida-restaurant-and-lodging-association-strengthens-efforts-in-palm-beach-by-welcoming-new-chapter-director- https://www.frla.org/news-release/the-florida-restaurant-and-lodging-association-strengthens-efforts-in-palm-beach-by-welcoming-new-chapter-director/ 

RedirectMatch 301 /frla-news/item/1468-hospitality-industry-executives-share-secrets-of-success-at-frlas-marketingoperations-summit https://www.frla.org/frla-news/item/1468-hospitality-industry-executives-share-secrets-of-success-at-frlas-marketingoperations-summit 

RedirectMatch 301 /frla-news/item/1472-frlas-regulatory-compliance-services-welcomes-new-northwest-florida-regional-manager https://www.frla.org/news-release/frlas-regulatory-compliance-services-welcomes-new-southeast-florida-regional-sales-manager/ 

RedirectMatch 301 /frla-news/item/1471-frla-endorses-governor-rick-scott-for-november-2014-election https://www.frla.org/news-release/frla-endorses-governor-rick-scott-for-november-2014-election/ 

RedirectMatch 301 /frla-news/item/1473-gov-scott-florida-tourism-on-pace-for-another-record-year- https://www.frla.org/news-release/gov-scott-florida-tourism-on-pace-for-another-record-year/ 

RedirectMatch 301 /frla-news/item/1474-endless-summer-music-series-brings-nashvilles-top-songwriters-to-destin-florida-for-free-concerts https://www.frla.org/news-release/endless-summer-music-series-brings-nashvilles-top-songwriters-to-destin-florida-for-free-concerts/ 

RedirectMatch 301 /frla-news/item/1486-frlas-tallahassee-chapter-installs-new-officers-and-board-of-directors-for-2015 https://www.frla.org/news-release/frlas-tallahassee-chapter-installs-new-officers-and-board-of-directors-for-2015/ 

RedirectMatch 301 /frla-news/item/1487-frlas-broward-chapter-installs-new-officers-and-board-of-directors-for-2015 https://www.frla.org/news-release/frlas-broward-chapter-installs-new-officers-and-board-of-directors-for-2015/ 

RedirectMatch 301 /frla-news/item/1485-frlas-palm-beach-chapter-installs-new-officers-and-board-of-directors-for-2015 https://www.frla.org/news-release/frlas-palm-beach-chapter-installs-new-officers-and-board-of-directors-for-2015/ 

RedirectMatch 301 /frla-news/item/1513-chef-emeril-lagasse-tours-family-owned-and-operated-restaurants-on-latest-episode-of-emerils-florida https://www.frla.org/news-release/chef-emeril-lagasse-tours-family-owned-and-operated-restaurants-on-latest-episode-of-emerils-florida-2/ 

RedirectMatch 301 /frla-news/item/1519-frlaef-announces-winners-of-hospitality-and-tourism-management-program-competition https://www.frla.org/news-release/frlaef-announces-winners-of-hospitality-and-tourism-management-program-competition/ 

RedirectMatch 301 /frla-news/item/1520-chef-emeril-lagasse-tours-kissimmee-on-latest-episode-of-emerils-florida https://www.frla.org/news-release/64807/ 

RedirectMatch 301 /educational-foundation/item/198-prostart-school-to-career-program https://www.frla.org/educational-foundation/prostart/ 

RedirectMatch 301 /educational-foundation/item/200-lodging-management-program https://www.frla.org/educational-foundation/htmpstart/ 

RedirectMatch 301 /frla-news/item/1529-member-spotlight-focus-on-guest-experiences-fuels-sustained-turnaround-at-steak-n-shake https://www.frla.org/news-release/member-spotlight-focus-on-guest-experiences-fuels-sustained-turnaround-at-steak-n-shake/ 

RedirectMatch 301 /frla-news/item/1530-nashvilles-top-songwriters-to-help-raise-money-for-childrens-charities-at-south-walton-beaches-wine-a-food-festival https://www.frla.org/news-release/nashvilles-top-songwriters-to-help-raise-money-for-childrens-charities-at-south-walton-beaches-wine-food-festival-2/ 

RedirectMatch 301 /frla-news/item/1532-more-than-150-songwriters-head-to-southernmost-point-for-20th-annual-festival-may-6-10-2015 https://www.frla.org/news-release/more-than-150-songwriters-head-to-southernmost-point-for-20th-annual-festival-may-6-10-2015/ 

RedirectMatch 301 /images/M_images/frla%202015%20legislative%20scorecard_updated.pdf https://www.frla.org/wp-content/uploads/2015/05/frla-2015-legislative-scorecard_updated1.pdf 

RedirectMatch 301 /frla-news/item/1537--tallahassee-restaurants-to-offer-fantastic-food-at-mouth-watering-prices-during-capital-cuisine-restaurant-week-and-concert-series-may-14-26 https://www.frla.org/news-release/release-1/ 

RedirectMatch 301 /frla-news https://www.frla.org/newsroom 

</IfModule> 

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteRule ^([_0-9a-zA-Z-]+/)?uploads/wpjobboard/application/(.+) /wp-content/plugins/wpjobboard/restrict.php?url=application/$2 [QSA,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 

# END WordPress 
+0

Вы хотите исключить страницу или ее каталог? Также нужно ли перенаправить на это? –

+0

Я просто хочу исключить одну страницу. Да, если к нему обращаются через https, ему необходимо перенаправить на http-версию. – joenammo

+0

Вы попробовали мой ответ, который я вам дал? –

ответ

1

Во-первых, спасибо за вашу помощь. Я очень ценю это. На всякий случай, это помогает кому-то еще, что я хочу опубликовать ответ, который я придумал.

Вместо выполнения перенаправления в файле htaccess я удалил весь этот код и установил собственную функцию Wordpress в файле functions.php. Кроме того, в настройках Wordpress я устанавливаю URL-адрес Wordpress в качестве https-версии (это контролирует загрузку файлов, которые должны быть превышены https), но я установил URL-адрес сайта в http-версию. Это функция, которую я написал для обработки перенаправления ...

function force_https() { 
    $addr = $_SERVER['HTTP_HOST']; 
    $production_site = true; 

    if(preg_match('/localhost/', $addr) || preg_match('/developmentserver.com/', $addr)){ 
     $production_site = false; 
    } 

    //only redirect to SSL if it is on the production server. 
    if($production_site == true){ 
     if (!is_ssl() && !is_page('bill-tracker')) { 
     wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301); 
     exit(); 
     } 
     elseif (is_ssl() && is_page('bill-tracker')) { 
      wp_redirect('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301); 
      exit(); 
     } 
    } 
} 

//only enable for production sites 
add_action ('template_redirect', 'force_https', 1); 
1

Вы можете попробовать это правило для своего .htaccess. если вы хотите исключить example-page из перенаправления https. Замените свое текущее правило.

RewriteCond %{HTTPS} !^on 
RewriteRule ^((?!example-page/?$).*)$ https://frla.org/$1 [R=301,L] 

RewriteCond %{HTTPS} ^on 
RewriteRule ^(example-page/?)$ http://frla.org/$1 [R=301,L]