【问题标题】:URL rewriting refused to work with codeigniterURL 重写拒绝与 codeigniter 一起使用
【发布时间】:2016-12-02 08:33:33
【问题描述】:

我想重写这个网址:

bookingstyles/search-treatment?search_service_hidden=89&service_group_id_hidden=

给这样的东西:

/bookingstyles/search-treatment/89/

我尝试过使用这个 .htaccess 规则:

RewriteEngine On 
RewriteRule /([0-9]+)/([0-9]+)/$ http://localhost/bookingstyles/search-treatment.php?search_service_hidden=$1&service_group_id_hidden=$2 [L]

但我仍然得到相同的旧网址。

【问题讨论】:

  • 嗨,Addy,欢迎来到 Stack Overflow。我已经编辑了您的问题以使 URL 更清晰(更具可读性);请记住,在此站点上,鼓励其他用户和您edit 您的问题尽可能地改进它。祝你好运!

标签: .htaccess codeigniter mod-rewrite


【解决方案1】:

您是否修改了 php 文件中的代码/链接?

我认为不需要在 Rewite 规则中指定整个 url,而是可以使用 {HTTP_HOST}%{REQUEST_URI}

试试这个

RewriteRule ^bookingstyles/(.+)/(.+)\.html$ search-treatment.php?id=$2&name=$1 [nc]

设置虚拟主机是更好的解决方案。以下链接可能会有所帮助。

https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite-for-apache-on-ubuntu-14-04

.htaccess not working on localhost with XAMPP

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-03
    • 2013-01-30
    • 1970-01-01
    • 2011-06-14
    • 1970-01-01
    相关资源
    最近更新 更多