重写 codeigniter 站点的 htaccess
我想重写 codeigniter url 重写的代码。
我使用了以下代码。
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 效果很好。 但它不适用于网址重写,
我希望 example.com/admin
变为 example.com/administration
和
example.com/video/123/title< /code> 变为
example.com/videos/details/123/title
提前致谢, w3父亲
I want to rewrite code for codeigniter url rewrite.
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
It is working well for index.php removal.
But it doesn't work for url rewrite
i want example.com/admin
becomes example.com/administration
and
example.com/video/123/title
becomes example.com/videos/details/123/title
Thanks in advance,
w3father
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该使用以下 .htaccess:
并将您的路由添加到 application/config 文件夹内的 paths.php 中。有关详细信息,请参阅 URI 路由。
You should use the following .htaccess:
And add your routes to the routes.php inside the application/config folder. See URI Routing for more information.
我相信您所需要做的就是将两条新规则放在现有规则之前。
I believe all you need to do is put your two new rules in front of the existing ones.