0

Trying to redirect all to https://www.....com/....

From :
http
non-www

to

https://www...... format

I have already tried following :

RewriteEngine on
RewriteCond %{HTTPS} !1 [NC]
RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
RewriteCond %{HTTP:X-Forwarded-SSL} !on [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI}$1 [R=301,L,QSA]

Environment ##

Ubuntu 22.04 LTS
Apache 2.4
SSL on

PHP Zend Framework, under public folder .htaccess ##

RewriteEngine On

The following rule tells Apache that if the requested filename exists, simply serve it.

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [L]

The following rewrites all other queries to index.php. The
condition ensures that if you are using Apache aliases to do
mass virtual hosting or installed the project in a subdirectory,
the base path will be prepended to allow proper resolution of
the index.php file; it will work in non-aliased environments
as well, providing a safe, one-size fits all solution.

RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.)::\2$
RewriteRule ^(.
) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}/index.php [L]

Enable gzip compression

AddOutputFilterByType DEFLATE text/html text/xml text/plain text/css text/javascript
application/javascript application/json application/font-woff application/font-woff2 image/svg+xml

<Files ~ ".(jpe?g|png|gif|css|js|woff|woff2|ttf|svg|webp|eot|ico)$">

  <ifModule mod_headers.c> <br />
       Header set Cache-Control "max-age=31536000, public" <br />
   </ifModule> <br />

   IfModule mod_expires.c <br />
       ExpiresActive on <br />
       ExpiresDefault "access plus 1 year" <br />
   IfModule <br />


Disables auto directory index

IfModule mod_autoindex.c
Options -Indexes
IfModule

IfModule mod_negotiation.c
Options -MultiViews
IfModule

IfModule mod_headers.c
Header append X-Frame-Options SAMEORIGIN
Header always set Strict-Transport-Security "max-age=31536000"
IfModule

Please Help

  • This question is very hard to read. When redacting a domain you can use example.com which is set aside specifically for this purpose. It is really hard to read when you jump from screaming headers to config – Chris Haas Sep 28 '22 at 21:13
  • You need to correct the _formatting_ of your question. [StackOverflow uses _markdown_](https://stackoverflow.com/help/formatting) to format posts (use the toolbar and help docs in the editor). No need to use HTML to format. – MrWhite Sep 29 '22 at 03:43

0 Answers0