.htaccess 删除index.php并重定向到https域
.htaccess文件:.htaccess 删除index.php并重定向到https域,.htaccess,codeigniter,subdomain,.htaccess,Codeigniter,Subdomain,.htaccess文件: RewriteEngine on RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA] Options -Indexes 我想从URL中删除index.php,当有人在地址栏中输入test.x
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Options -Indexes
我想从URL中删除index.php
,当有人在地址栏中输入test.xyz.com
时,它应该重定向到https://test.xyz.com
我通过注释上面的代码尝试了下面的一些代码,然后问题是当我输入test.xyz.com
时,它会自动重定向到https://test.xyz.com
但是当我转到像https://test.xyz.com/user/list
其显示错误
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
因此,我需要一个更好的.htaccess文件,它将删除index.php
,并将我子域中的所有URL重定向到https
注意:需要上述两种的组合版本。htaccess
代码
您可以在站点根目录中使用此代码。htaccess:
DirectoryIndex index.php
Options -Indexes
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,NE,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [L]
清除浏览器缓存或在新浏览器中测试后进行测试。无法访问url错误。当我使用第二个
.htaccess
代码时,我知道问题在于我没有从url中删除index.php
,这意味着如果我使用https://test.xyz.com/index.php/user/list
它将很好地工作第一个是我最初使用的唯一代码。即删除index.php
。在那之后,我评论了所有的代码,并尝试了第二个。当然可以。但是http://test.xyz.com/user/list
不起作用。i、 e如果我们仅使用第一个块规则删除httpsYeshttps://test.xyz.com/user/list
url有效。完美!!。很好。非常感谢你。