Programatically forcing https on MAMP Pro for specific pages (not site wide and without using .htaccess)

StackOverflow https://stackoverflow.com//questions/21038450

Вопрос

Is there a way of setting MAMP Pro up to use SSL for specific pages of a CMS site rather than a global site-wide enforcing of SSL.

A SilverStripe site we are working on requires only portions of the site to be secure and so we programmatically enforce this using Director::forceSSL on the specific areas of the site. It works well on the live production site - real host / domain.

When I enable SSL in MAMP Pro on our dev machine it is applied site-wide and I can only access the site with https://mysite.local:8890/. In other words is there a way of having the self-signed certificate in MAMP Pro installed but not used unless (programatically) enforced, without touching the .htaccess file?

Это было полезно?

Решение

I fear this is not possible. Your options might be:

  • htaccess
  • CMS

htaccess
Force HTTPS on certain sites:

# Force HTTPS for /my
RewriteCond %{HTTPS} !=on
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/my [NC]
RewriteRule ^(my) https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]

CMS
Force HTTPS on certain pages with your CMS.
In your case this could help.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top