在codeigniter中从URL中删除了WWW,控制器无法访问

时间:2015-05-13 12:59:47

标签: php codeigniter

我想在运行应用程序时在localhost上运行我的CodeIgniter应用程序,网址似乎是https://www.localhost/projects/4all/
然后我对.htaccess进行了更改,www已被删除,但我的控制器现在无法访问.e.g

当我输入localhost/projects/4all/时,它会显示一个空白页。

它不会重定向到routes.php

中的控制器定义 在我做出更改之前


.htaccess

<ifModule mod_gzip.c>
  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file \.(html?|txt|css|js)$
  mod_gzip_item_include handler ^cgi-script$
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_exclude mime ^image/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^(www)\.(.*)\.(.*)\.(.*) [NC]
RewriteRule ^(.*)$ http://%2.%3.%4/$1 [R=301,QSA,L]

#force www on production domain

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]



DirectoryIndex index.php
Options -Indexes

RewriteRule ^combine/(.*)$ /application/cache/smarty/cached/$1 [L]

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt|sitemap\.rss)

RewriteRule ^(.*)$ index.php?/$1 [L]
我做出更改后

.htaccess

# Turn on URL rewriting
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

如果需要一些额外的数据,请评论我。

1 个答案:

答案 0 :(得分:-1)

您无法在localhost上运行https://www.localhost/projects/4all/之类的基本URL。 应将其指定为http://localhost/projects/4all/