在mod_rewrite的URL中的特殊字符 [英] Special characters in mod_rewrite url

查看:289
本文介绍了在mod_rewrite的URL中的特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望这个网址:

http://www.mydomainblabla.com/s/can+you+drill+shrinky+dinks?.html

要改写为这一个:

http://www.mydomainblabla.com/search.php?q=can+you+drill+shrinky+dinks?

我用这mod_rewrite的规则,在我的.htaccess做到这一点

I am using this mod_rewrite rule in my .htaccess to accomplish this

RewriteRule ^s/(.+).html$ search.php?q=$1 [L,QSA]

但是,结果并不像我想的那样,当我去的第一个URL,我得到一个网页未找到消息。

However, the result is not as I want it, when I go to the first url, I get a page not found message.

同样的问题发生在我访问这个网址:

The same problem occurs when I visit this url:

http://www.mydomainblabla.com/s/http://www.zakgeldnodig.nl/.html

这应该被改写成这样:

which should be rewritten into this one:

http://www.mydomainblabla.com/search.php?q=http://www.zakgeldnodig.nl/

我应该让我的.htaccess什么修改,使这项工作?

What modifications should I make to my .htaccess to make this work?

推荐答案

的httpd.conf 启用了mod_rewrite和.htaccess,然后把这个code在< $ C C>的.htaccess $ DOCUMENT_ROOT 目录下:

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+s/(.+?)\.html [NC]
RewriteRule ^ search.php?q=%1 [L,NE]

这篇关于在mod_rewrite的URL中的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆