[英]Improving .htaccess with SSL and WWW on Codeigniter
I am trying to make SSL and Redirection work perfectly with my web application. 我正在尝试使SSL和重定向与我的Web应用程序完美配合。 I wish to achieve that always https://www.mydomain.com/ should be loaded in the browser - although, if he types a subdomain - it should be redirected to https://subdomain.mydomain.com/ instead.
我希望实现这一点始终https://www.mydomain.com/应该在浏览器中加载 - 但是,如果他键入子域名 - 它应该被重定向到https://subdomain.mydomain.com/ 。
I mean to say, everything should be SSL - here is what I am doing currently 我的意思是说,一切都应该是SSL - 这就是我目前正在做的事情
Options -Indexes
Options +FollowSymLinks
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www) [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !index.php
RewriteRule (.*)\.php$ index.php/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
Also, I wish to improve this .htaccess file so to introduce more security measures plus also allow only js, css and images files to be accessible by everyone - rest everything hidden or redirected to a 404 page. 此外,我希望改进这个.htaccess文件,以便引入更多安全措施,并且只允许每个人访问js,css和图像文件 - 将所有内容隐藏或重定向到404页面。
Please guide, I would be greatly thankful! 请指导,我将非常感谢!
These rewrite conditions may help you, I use this to make my CodeIgniter go to HTTPS: 这些重写条件可能会对您有所帮助,我使用它来使我的CodeIgniter转到HTTPS:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.