我在编码器路由方面遇到了一些麻烦。我有一个活的网站在托管服务器&这是它的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)非常有效&主机服务器。在头部。视图,在其他视图中,链接以
形式给出。<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等。
我已经尝试了所有可能的方法使它工作,请指出我做错的地方。谢谢大家
这是我的.htaccess
,它适用于生产和开发服务器。
RewriteEngine on
RewriteCond $1 !^(index'.php|resources|robots'.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
config。
$config['base_url'] = '';
$config['index_page'] = '';
routes.php
# Default
$route['default_controller'] = "home";
1。在application/config.php
文件
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
2。使用下面的代码
在根目录下创建.htacces
文件RewriteEngine on
RewriteBase /codeigniter // add this
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
我尝试了上面所有的解决方案,但没有一个适合我,所以我把事情推到周围,现在我的本地服务器工作得很好
下面是你需要做的:正如Saty所说
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
然后添加以下htaccess代码:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]