htaccess的重写为codeigniter网站 [英] htaccess rewrite for codeigniter site
本文介绍了htaccess的重写为codeigniter网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想重写$ C $下codeigniter URL重写。
I want to rewrite code for codeigniter url rewrite.
我已经使用下列code。
I have used following code.
RewriteEngine On
RewriteBase /whype
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteRule ^admin$ administration
RewriteRule ^video/([0-9]+)/(.*)$ videos/details/$1/$1
这是运作良好的index.php文件删除。 不过,这并不为URL重写工作
It is working well for index.php removal. But it doesn't work for url rewrite
我想 example.com/admin
变为 example.com/administration
和
example.com/video/123/title
变成 example.com/videos/details/123/title
在此先感谢, w3father
Thanks in advance, w3father
推荐答案
您应该使用下面的.htaccess:
You should use the following .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 see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
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>
和你的路由添加到应用程序/ config文件夹里面的routes.php文件。请参见 URI路由了解详情。
And add your routes to the routes.php inside the application/config folder. See URI Routing for more information.
这篇关于htaccess的重写为codeigniter网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文