重写URL Codeigniter

编程入门 行业动态 更新时间:2024-10-28 15:33:14
本文介绍了重写URL Codeigniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在为我的Web应用程序使用Codeigniter,我将项目的结构更改如下:

i'm using Codeigniter for my web app, i changed the structure of the project as the following :

my_Project --- application --- public_html --- resources --- system

我创建了文件夹public_html来将我的公共文件与类..等分开,但是现在我每次必须调用此url:

I created the folder public_html to seperate my public files from the classes .. etc, but now i have to call this url every time :

my_project/public_html/controller/action

我希望这样:

my_project/controller/action

我已经使用重写模式从URL中移出了index.php,但我似乎也无法删除public_html:

I already moved out the index.php from the URL using the rewrite mode, but i can't seem to remove the public_html as well :

.htaccess

.htaccess

<IfModule mod_rewrite.c> # 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 /uca-flsh/public_html # 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|favicon\.ico|public|assets|css|js|images|resources|public_html) # No rewriting RewriteRule ^(.*)$ - [PT,L] # Rewrite to index.php/URL RewriteRule ^(.*)$ index.php/$1 [PT,L] </IfModule>

.config.php

.config.php

$config['base_url'] = 'localhost/uca-flsh/public_html';

推荐答案

尝试使用此功能:

RewriteCond %{THE_REQUEST} /my_project/public_html/controller/action [NC] RewriteRule ^ my_project/controller/action [L,R]

更多推荐

重写URL Codeigniter

本文发布于:2023-10-31 17:10:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546738.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   URL   Codeigniter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!