【问题标题】:Codeigniter URL Routing IssueCodeigniter URL 路由问题
【发布时间】:2015-09-08 09:45:49
【问题描述】:

我是 codeigniter 的新手,想在网站上设置我的 URL,目前我使用的是 3.0.1 版 URL 看起来像

http://oti.nhmp.net/index.php/site/about_us

我想要这样的

http://oti.nhmp.net/about_us

我已经在路由文件中尝试过 URL 路由,但它不适合我这里是代码

routes.php

$route['default_controller'] = 'site';
$route['about_us'] = "index.php/site/about_us";
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

.htaccess

<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

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

</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

ErrorDocument 404 /index.php

</IfModule>

【问题讨论】:

  • 您是否收到 404 错误??
  • 没有页面正在完美打开,但只是想更改 URL
  • 这里是Website URL

标签: php codeigniter url router


【解决方案1】:

像这样更改关于我们的href

<a href="http://oti.nhmp.net/about_us">About Us</a>

【讨论】:

  • 你在routes.php中指定路由了吗??
  • 我现在正在使用这个&lt;a href="&lt;?php echo base_url(); ?&gt;index.php/site/about_us"&gt;About Us&lt;/a&gt;
  • 将其更改为 ">关于我们 并在 routes.php 文件中指定 about_us 的路由跨度>
  • 我更新了路由器并链接了两者,但得到 404 错误
  • 我用路由器代码更新了问题,请检查
猜你喜欢
  • 2016-02-04
  • 1970-01-01
  • 1970-01-01
  • 2011-09-23
  • 2015-07-10
  • 1970-01-01
  • 1970-01-01
  • 2023-03-24
相关资源
最近更新 更多