【问题标题】:Converting Standard Request Uri Into Clean URL using .htaccess使用 .htaccess 将标准请求 Uri 转换为干净 URL
【发布时间】:2010-10-14 11:29:31
【问题描述】:

我有一个格式如下的网址:

http://domain.com/checkout/nonce/701fe0f652/order/108/?token=EC-0DS37792JX3680821

我尝试使用 .htaccess 将其转换为干净的 URL:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?token=(.*)$ /index.php/$1/token/$2/ [R]

RewriteRule 不知何故不起作用。我已经使用http://jakarta.apache.org/regexp/applet.html 对其进行了测试,结果完全匹配。

我正在使用 CodeIgniter,并且已经测试直接放置干净的 URL (http://domain.com/checkout/nonce/701fe0f652/order/108/token/EC-0DS37792JX3680821) 没有问题。

有人可以帮帮我吗?

谢谢。

最好的问候。

【问题讨论】:

    标签: regex .htaccess clean-urls


    【解决方案1】:

    我已经找到答案了

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{QUERY_STRING} ^token=([a-zA-Z0-9\-]+)
    RewriteRule ^([a-z0-9\/\-.]+)$ $1token/%1? [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 2016-12-21
      • 1970-01-01
      • 1970-01-01
      • 2016-04-24
      • 2014-02-09
      • 1970-01-01
      • 2011-01-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多