【问题标题】:apache htaccess codeigniter query string to pathapache htaccess codeigniter查询字符串到路径
【发布时间】:2013-06-29 12:43:50
【问题描述】:

我正在尝试使基于 codeigniter 的网站能够使用 .htaccess 将 index.php?option=test&controller=con1 转换为 /test/con1 我尝试了多个我发现的示例,但似乎没有一个有效,它直接主页。有什么想法吗?

我尝试过类似的东西

RewriteCond %{QUERY_STRING} ^(\w+)=(\w+)$
RewriteRule ^\/(.+?)\/(.+?)\/?   /index.php/$1/$2 [L]

但不会抛出任何错误或任何东西。 我目前的 htacces 是

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|img|js|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L]

【问题讨论】:

    标签: php string codeigniter path


    【解决方案1】:

    尝试将此 .htaccess 与您的 index.php 放在同一目录中

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    

    【讨论】:

    • 将 rewritecond 之一移动到不同的位置?
    • 尝试用上面提供的 i 替换您当前的 htaccess
    • 好吧,我做了,没有发现任何区别,仍然忽略 GET 参数。
    猜你喜欢
    • 2011-03-07
    • 2016-03-26
    • 2019-01-02
    • 2018-12-02
    • 1970-01-01
    • 2012-10-11
    • 1970-01-01
    • 2022-11-21
    • 2022-01-18
    相关资源
    最近更新 更多