dtslobe4694 2017-06-03 15:46
浏览 105

CodeIgniter项目.htaccess问题

I want to install a codeigniter project on a GoDaddy hosting.

I've followed the Godaddy Installation Tips instructions from the CodeIgniter Wiki.

In config.php

$config['index_page'] = "index.php?";
$config['uri_protocol'] = "QUERY_STRING";

In .htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]

I can access everything as such

http://yourdomain.com/controller/action/etc

But

When I have a get parameters in url

http://yourdomain.com/controller/action/etc?id=1

The .htaccess remove the parameter ?id=1 so

http://yourdomain.com/controller/action/etc?id=1

become

http://yourdomain.com/controller/action/etc
  • 写回答

1条回答 默认 最新

  • douyudouchao6779 2017-06-03 16:40
    关注

    Try this code in .htaccess:

    DirectoryIndex index.php
    # Turn on URL rewriting
    RewriteEngine On
    
    # If your website begins from a folder e.g localhost/my_project then 
    # you have to change it to: RewriteBase /my_project/
    # If your site begins from the root e.g. example.local/ then
    # let it as it is
    
    RewriteBase /
    
    
    # Protect application and system files from being viewed when the index.php is missing
    RewriteCond $1 ^(application|system|private|logs)
    
    # Rewrite to index.php/access_denied/URL
    RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
    
    # Allow these directories and files to be displayed directly:
    RewriteCond $1 ^(index\.php|robots\.txt|opensearch\.xml|favicon\.ico|assets|forums)
    
    # No rewriting
    RewriteRule ^(.*)$ - [PT,L]
    
    # Rewrite to index.php/URL
    RewriteCond %{REQUEST_URI} !^(.+)\.(js|css|gif|png|jpg|jpeg|bmp|swf|txt|xml|htc|pdf|xls|doc|ico)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [PT,L]
    

    I used this in one of the project, and its working there...

    评论

报告相同问题?

悬赏问题

  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条