I have the following setup. Flexible Beanstalk environment with load balancer. The web application installed in the root directory uses CodeIgniter. Wordpress is installed in a subdirectory / blog from the root. CodeIgniter application requires https, but wordpress must be http. The load balancer is configured to listen on https and http, the instances behind the load balancer are http.
My first configuration to manage this .ebextensions file is at the root. This file is deployed with the application to install .conf to redirect all HTTP traffic to https EXCEPT / blog. This file is as follows:
files: "/etc/httpd/conf.d/ssl_rewrite.conf": mode: "000644" owner: root group: root content: | RewriteEngine On <If "-n '%{HTTP:X-Forwarded-Proto}' && %{HTTP:X-Forwarded-Proto} != 'https'"> RewriteCond %{REQUEST_URI} !^/blog/ RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L] </If>
The next step in the configuration is the .htaccess file in the root. This controls the CI requests. It looks like this:
<FilesMatch "\.(ttf|otf|eot|woff|woff2|svg)$"> <IfModule mod_headers.c> Header set Access-Control-Allow-Origin "*" </IfModule> </FilesMatch> RewriteEngine on RewriteBase / RewriteCond $1 !^(index\.php|uploads|blog|assets|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] Options -Indexes
Finally, in the / blog directory containing Wordpress, I have this .htaccess
RewriteEngine On RewriteBase /blog/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L]
The CI application works fine, and HTTP requests are sent to https correctly. The root / blog directory itself (i.e., the "Homepage", for example http://example.com/blog ) also works fine. Even the / blog / subcategories such as http://example.com/blog/wp-admin/options-general.php work fine. What doesn't work is permalinks such as http://example.com/blog/my-article (presumably because they are not real files). If I changed the permalink setting to remove permalinks and allow email URLs to look like this: http://example.com/blog/?p=123 , which also works. Only permalinks do not work.
An additional problem (which should be obvious) is that if someone tries to directly access the blog using https, they will receive a warning about mixed content and broken links. Therefore, I also need to redirect https://example.com/blog/ * back to http.
I'm sure this setting is more complicated, and I could delete both .htaccess files and put all my settings in the .ebextensions configuration file, but I'm not sure how to do this. Over the course of a few days, I collected several solutions, such as and, and each solution creates another problem.
For those who are going to assume that Wordpress should also be https, I am not opposed to this, however, I have been on this path for more than a week without a good solution that allows me to support a testing and development environment other than ssl which will automatically be implemented in AWS without useless plugins, files that change during the production process, which I cannot easily return back to testing and dev, as well as to many other https / wordpress problems. The simplest solution seems to work with Wordpress http. I am also open to another CMS to replace Wordpress. Bottom line: I just want the blog to work in CI mode on AWS, in https / http, play well together and easily deploy.
It should also be noted that in dev and test everything works fine. The only significant difference between dev and test is the .ebextensions file and the https redirection.
Any help is appreciated.