【发布时间】:2015-08-08 03:00:39
【问题描述】:
我在使用 codeigniter 路由时遇到了一些问题。我在托管服务器中有一个实时站点,这是它的 htaccess。
#php_value memory_limit 256M
#php_value upload_max_filesize 50M
#php_value post_max_size 70M
AddType font/opentype .otf
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType application/font-woff .woff
AddDefaultCharset utf-8
<IfModule mod_rewrite.c>
RewriteEngine on
Options +FollowSymLinks
RewriteBase /
RewriteRule ^favicon.* - [L]
RewriteRule ^search /categories [R=301,L]
RewriteRule ^login / [R=301,L]
RewriteRule ^pages/disclaimer /pages/integritetspolicy [R=301,L]
RewriteRule ^(.*)/$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^index.php$ http://%{HTTP_HOST} [R=301,L]
RewriteCond %{HTTP_HOST} !^example\.com
RewriteRule (.*) http://example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (utredningar/post)
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301]
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !(utredningar/post)
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
这与域名 (example.com) 和托管服务器完美配合。在 header.view 和其他视图中,链接以
形式给出<href="/assets/styles/home.css?9">
但是当我尝试在 wamp 的 localhost 中进行这项工作时,它不起作用。资产( css / js / images )未加载且 url 路由不起作用。
这两行我都修改了
RewriteCond %{HTTP_HOST} !^example\.com
RewriteRule (.*) http://example.com/$1 [R=301,L]
到
RewriteCond %{HTTP_HOST} !^localhost
RewriteRule (.*) http://localhost/example/$1 [R=301,L]
我更改了 application/config/config.php ,添加了基本 url ,删除了 index.php 等 ..
我已经尝试了所有可能的方法来使它工作,请指出我在哪里做错了..非常感谢
【问题讨论】:
-
您使用哪个版本的 CI??
-
它是 2.1 ,但我也将系统更改为 2.2 .. 仍然无法正常工作..
-
你在用godaddy服务器吗?
-
不是它不在godaddy中,在另一个托管服务器中的实时网站,live一个完美运行,但我不能让它成为localhost .. :(
-
如果您说资产也没有加载,那么您的服务器一定有配置问题。您确定正在读取文件吗?如果将
abcdefgh0123放在文件开头,会引发内部服务器错误吗?
标签: php .htaccess codeigniter routing