Forum Moderators: phranque
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#----- START PRODUCT NAME REM -----
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} (.*)/wp-content/uploads/(.*)
RewriteCond %{REQUEST_FILENAME} !(.*)(\.php|\.css|\.js|\.jpg|\.gif|\.png|\.txt|\.ico|\.jpeg)$
RewriteRule (.*) /peoductname/client/website/productname client.php?productnameref=%{REQUEST_URI}&plug=wp&%{QUERY_STRING} [L]
#----- END PRODUCT NAME REM -----
</IfModule>
RewriteEngine on RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !/signup/
RewriteRule (.*) https://www.example.com/$1 [R=301,L] RewriteCond %{HTTPS} on
RewriteRule ^signup/$ http://www.example.com/signup/ [R=301,L] RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !/sign[-]up/
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteRule ^signup/$ http://www.example.com/sign[-]up/ [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#----- START PRODUCT NAME REM -----
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} (.*)/wp-content/uploads/(.*)
RewriteCond %{REQUEST_FILENAME} !(.*)(\.php|\.css|\.js|\.jpg|\.gif|\.png|\.txt|\.ico|\.jpeg)$
RewriteRule (.*) /peoductname/client/website/productname client.php?productnameref=%{REQUEST_URI}&plug=wp&%{QUERY_STRING} [L]
#----- END PRODUCT NAME REM -----
</IfModule> [edited by: phranque at 6:41 pm (utc) on Mar 31, 2015]
[edit reason] unlinked URL [/edit]
sign[-]up
When I use the right one with the above code, the exempted page just redirects to the homepage.
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !/pick-an-ebook/
RewriteRule (.*) https://example.net/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteRule ^pick-an-ebook/$ http://example.net/pick-an-ebook/ [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#----- START DAP -----
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} (.*)/wp-content/uploads/(.*)
RewriteCond %{REQUEST_FILENAME} !(.*)(\.php|\.css|\.js|\.jpg|\.gif|\.png|\.txt|\.ico|\.jpeg)$
RewriteRule (.*) /dap/client/website/dapclient.php?dapref=%{REQUEST_URI}&plug=wp&%{QUERY_STRING} [L]
#----- END DAP -----
</IfModule>
# END WordPress
### HEADER CACHING
# /htaccess/speed-up-sites-with-htaccess-caching.html
<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
<FilesMatch "\.(js|css|pdf|swf)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
<FilesMatch "\.(html|htm|txt)$">
Header set Cache-Control "max-age=600"
</FilesMatch>
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control
</FilesMatch>
## ALTERNATE EXPIRES CACHING
# htaccesselite.com/d/use-htaccess-to-speed-up-your-site-discussion-vt67.html
ExpiresActive On
ExpiresDefault A604800
ExpiresByType image/x-icon A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType text/css A2592000
ExpiresByType text/html A300
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
ExpiresActive Off
</FilesMatch> [edited by: phranque at 4:15 am (utc) on Apr 5, 2015]
[edit reason] unlinked URL [/edit]
This is true both when using http and https in the address.
https://example.net/pick-an-ebook/
GET /pick-an-ebook/ HTTP/1.1
Host: example.net
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:36.0) Gecko/20100101 Firefox/36.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://example.net/
Cookie: __utma=142812215.786699786.1428246488.1428246488.1428246488.1; __utmb=142812215.5.10.1428246488; __utmc=142812215; __utmz=142812215.1428246488.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmt=1; PHPSESSID=mbcqae5uim8q7j5mpbppcfs0h4
Connection: keep-alive
HTTP/1.1 301 Moved Permanently
Date: Sun, 05 Apr 2015 03:50:48 GMT
Server: Apache/2.4.10 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4
Location: http://example.net/pick-an-ebook/
Cache-Control: max-age=300
Expires: Sun, 05 Apr 2015 03:55:48 GMT
Content-Length: 253
Connection: close
Content-Type: text/html; charset=iso-8859-1
----------------------------------------------------------
https://example.net/index.php
GET /index.php HTTP/1.1
Host: example.net
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:36.0) Gecko/20100101 Firefox/36.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: __utma=142812215.786699786.1428246488.1428246488.1428246488.1; __utmb=142812215.5.10.1428246488; __utmc=142812215; __utmz=142812215.1428246488.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmt=1; PHPSESSID=mbcqae5uim8q7j5mpbppcfs0h4
Connection: keep-alive
HTTP/1.1 301 Moved Permanently
Date: Sun, 05 Apr 2015 03:50:48 GMT
Server: Apache/2.4.10 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4
X-Powered-By: PHP/5.3.29
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding,Cookie
X-Pingback: https://example.net/xmlrpc.php
Location: https://example.net/
Content-Length: 0
Connection: close
Content-Type: text/html; charset=UTF-8
----------------------------------------------------------
https://example.net/
GET / HTTP/1.1
Host: example.net
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:36.0) Gecko/20100101 Firefox/36.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: __utma=142812215.786699786.1428246488.1428246488.1428246488.1; __utmb=142812215.5.10.1428246488; __utmc=142812215; __utmz=142812215.1428246488.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmt=1; PHPSESSID=mbcqae5uim8q7j5mpbppcfs0h4
Connection: keep-alive
HTTP/1.1 200 OK
Date: Sun, 05 Apr 2015 03:50:50 GMT
Server: Apache/2.4.10 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4
X-Powered-By: PHP/5.3.29
Vary: Accept-Encoding,Cookie
Cache-Control: max-age=3, must-revalidate
WP-Super-Cache: Served supercache file from PHP
Content-Encoding: gzip
Content-Length: 7588
Connection: close
Content-Type: text/html; charset=UTF-8
----------------------------------------------------------
https://ssl.google-analytics.com/ga.js
GET /ga.js HTTP/1.1
Host: ssl.google-analytics.com
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:36.0) Gecko/20100101 Firefox/36.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://example.net/
Connection: keep-alive
If-Modified-Since: Thu, 05 Feb 2015 17:35:24 GMT
HTTP/2.0 304 Not Modified
Age: 1214
Alternate-Protocol: 443:quic,p=0.5
Date: Sun, 05 Apr 2015 03:30:36 GMT
Expires: Sun, 05 Apr 2015 05:30:36 GMT
Server: GFE/2.0
X-Firefox-Spdy: h2-15
----------------------------------------------------------
https://ssl.google-analytics.com/__utm.gif?utmwv=5.6.3&utms=6&utmn=274685880&utmhn=example.net&utmcs=UTF-8&utmsr=1024x768&utmvp=605x582&utmsc=24-bit&utmul=en-us&utmje=0&utmfl=17.0%20r0&utmdt=Home%20%7C%20Affordable%20Online%20Distance%20Training%20Courses&utmhid=359033945&utmr=-&utmp=%2F&utmht=1428246874211&utmac=UA-0000000-0&utmcc=__utma%3D142812215.786699786.1428246488.1428246488.1428246488.1%3B%2B__utmz%3D142812215.1428246488.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct)%7Cutmcmd%3D(none)%3B&utmjid=&utmu=qAAAAAAAAAAAAAAAAAAAAAAE~
GET /__utm.gif?utmwv=5.6.3&utms=6&utmn=274685880&utmhn=example.net&utmcs=UTF-8&utmsr=1024x768&utmvp=605x582&utmsc=24-bit&utmul=en-us&utmje=0&utmfl=17.0%20r0&utmdt=Home%20%7C%20Affordable%20Online%20Distance%20Training%20Courses&utmhid=359033945&utmr=-&utmp=%2F&utmht=1428246874211&utmac=UA-0000000-0&utmcc=__utma%3D142812215.786699786.1428246488.1428246488.1428246488.1%3B%2B__utmz%3D142812215.1428246488.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct)%7Cutmcmd%3D(none)%3B&utmjid=&utmu=qAAAAAAAAAAAAAAAAAAAAAAE~ HTTP/1.1
Host: ssl.google-analytics.com
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:36.0) Gecko/20100101 Firefox/36.0
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://example.net/
Connection: keep-alive
HTTP/2.0 200 OK
Age: 130813
Alternate-Protocol: 443:quic,p=0.5
Cache-Control: private, no-cache, no-cache=Set-Cookie, proxy-revalidate
Content-Length: 35
Content-Type: image/gif
Date: Fri, 03 Apr 2015 15:30:37 GMT
Expires: Wed, 19 Apr 2000 11:43:00 GMT
Last-Modified: Wed, 21 Jan 2004 19:51:30 GMT
Pragma: no-cache
Server: Golfe2
x-content-type-options: nosniff
X-Firefox-Spdy: h2-15
---------------------------------------------------------- [edited by: phranque at 4:12 am (utc) on Apr 5, 2015]
[edit reason] unlinked URLs [/edit]
GET /pick-an-ebook/ HTTP/1.1
...
HTTP/1.1 301 Moved Permanently
...
Location: http://example.net/pick-an-ebook/
...
----------------------------------------------------------
https://example.net/index.php
GET /index.php HTTP/1.1
Perhaps the Wordpress code needs to be before the exemption code instead of after?
GET /index.php HTTP/1.1Whoa there. Something is seriously wrong. Yes, a CMS site is entirely built upon index.php -- but it would never, ever come through as an explicit GET request. It's done with behind-the-scenes rewriting; the browser should never even know the page exists.
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !/pick-an-ebook/
RewriteRule (.*) https://example.net/$1 [R=301,L]
Uh-oh, this doesn't exclude internal requests. If a request has been rewritten to index.php, and is sent back through the whole Apache system, it will meet this rule. And you will then get an unintended external redirect to index.php by name. RewriteCond %{REQUEST_URI} !/(pick-an-ebook|index\.php)
or, in the alternative, duplicate the line RewriteRule ^index\.php - [L]
and put it at the very beginning of your RewriteRules. You have to duplicate it, rather than simply move it, because nothing inside your WP envelope (was it WP? whatever the ### CMS we're talking about) should be touched. Except I'd want to make a further exclusion involving %{THE_REQUEST} since nobody should be allowed to ask for "index.php" by name... # BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule> Message on Firefox states that the server is redirecting in a way that will never complete
RewriteRule ^index\.php$ - [L]
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !/pick-an-ebook/
RewriteRule (.*) https://example.net/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteRule ^pick-an-ebook/$ http://example.net/pick-an-ebook [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#----- START DAP -----
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} (.*)/wp-content/uploads/(.*)
RewriteCond %{REQUEST_FILENAME} !(.*)(\.php|\.css|\.js|\.jpg|\.gif|\.png|\.txt|\.ico|\.jpeg)$
RewriteRule (.*) /dap/client/website/dapclient.php?dapref=%{REQUEST_URI}&plug=wp&%{QUERY_STRING} [L]
#----- END DAP ----- [edited by: phranque at 7:51 pm (utc) on Apr 14, 2015]
[edit reason] exemplified URLs [/edit]
https://example.net/pick-an-ebook
GET /pick-an-ebook HTTP/1.1
Host: example.net
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:36.0) Gecko/20100101 Firefox/36.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: __utma=142812215.326810114.1429041480.1429041480.1429041480.1; __utmb=142812215.1.10.1429041480; __utmc=142812215; __utmz=142812215.1429041480.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmt=1; PHPSESSID=r56lfk5cg4pc5kq36tscake2o4
Connection: keep-alive
HTTP/1.1 301 Moved Permanently
Date: Tue, 14 Apr 2015 19:58:44 GMT
Server: Apache/2.4.10 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4
X-Powered-By: PHP/5.3.29
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding,Cookie
X-Pingback: https://example.net/xmlrpc.php
Location: https://example.net/pick-an-ebook/
Content-Length: 0
Connection: close
Content-Type: text/html; charset=UTF-8
------------ [edited by: phranque at 7:53 pm (utc) on Apr 14, 2015]
[edit reason] unlinked URLs [/edit]