重写URL以在.htaccess一个非打破空间 [英] Rewrite a url with one non-breaking space in .htaccess
本文介绍了重写URL以在.htaccess一个非打破空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下URL(有几个这样的):
I have the following url (there are a few like these):
mysite.co.uk/productdetails/408/20/Casio%C2%A0CTK1100/
和我想将它改写为:
mysite.co.uk/Casio-CTK1100-in-Black/393
现在的问题是这个有趣%C2%A0 现在我有多个空格等环节在那里,他们被改写为:
The problem is this funny %C2%A0 now I have other links with multiple spaces in there and they are rewritten as follows:
# take care of %C2%A0
RewriteRule ^(.+)\xc2\xa0(.+)$ $1-$2 [L,NE]
# executes **repeatedly** as long as there are more than 1 spaces in URI
RewriteRule "^(\S*) +(\S* .*)$" $1-$2 [L,NE]
RewriteRule "^productdetails/617/6/(\S*) (\S*?)/?$" /$1-$2/302 [L,R=302,NE] (is just and example of a url with more than 1 space)
本作品prefect,但是当URL只中有一个空格像上面显示它不会工作之一。我需要保持上述规则在我的.htaccess文件,以便能够重写URL的多个空间。
This works prefect, however when the url only has one space in it like the one shown above it will not work. I will need to keep the above rule in my .htaccess file to be able to rewrite the urls with multiple space.
任何帮助的欢迎。
推荐答案
您可以把它像这样的:
# take care of %C2%A0
RewriteRule ^(.+)\xc2\xa0(.+)$ $1-$2 [L,NE]
# executes **repeatedly** as long as there are more than 1 spaces in URI
RewriteRule "^(\S*) +(\S* .*)$" $1-$2 [L,NE]
RewriteRule "^productdetails/617/6/(\S*) (\S*?)/?$" /$1-$2/302 [L,R=302,NE]
RewriteRule "^productdetails/408/20/(\S+?)/?$" /$1-in-Black/393 [L,R=302,NE]
这篇关于重写URL以在.htaccess一个非打破空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文