Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 删除index.php并重定向到https域_.htaccess_Codeigniter_Subdomain - Fatal编程技术网

.htaccess 删除index.php并重定向到https域

.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

.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.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如果我们仅使用第一个块规则删除https
Yes
https://test.xyz.com/user/list
url有效。完美!!。很好。非常感谢你。