大家好,你能帮助我在这里即时有一个小麻烦在这里IM特林使用htaccess的删除所有的20%,在我的网址,用连字符我设法摆脱其他的20%,在字与字之间宏基取代它,液体,S1,S510
hi guys can you help me here im having a little trouble here im tring to use the htaccess to remove all 20% in my url and replacing it with hyphen I manage to get rid the other 20% in between the words Acer,Liquid,S1,S510
下面是我的网址 /本地主机/小工具/产品/宏碁 - 液 - S1-S510%20Mobile
正如你可以看到有在最后一部分是20%,我怎么可以将其删除
As you can see there is one %20 in last part, how can I remove it
和这里是我的htaccess
And here is my htaccess
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /gadgets/
Options -Indexes
RewriteRule ^brand/([a-zA-Z]+)$ brand.php?id=$1
RewriteRule ^product/([A-Za-z0-9-]+)/?$ product.php?product_name=$1-$2 [NC,L]
RewriteRule ^(.*/|)[s%20]+(.+)$ $1$2 [L]
RewriteRule ^(.+?)[s%20]+(/.*|)$ $1$2 [L]
RewriteRule ^([^s%20]*)(?:s|%20)+(.*)$ $1-$2 [L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
在此先感谢你们
Thanks in advance guys
试试这个:
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On
RewriteBase /gadgets/
RewriteRule ^([^s%20]*)(?:s|%20)+(.*)$ $1-$2 [N,E=Redirect:1]
RewriteCond {ENV:Redirect} ^1$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R,L]
RewriteRule ^brand/([a-zA-Z]+)$ brand.php?id=$1 [NC,L]
RewriteRule ^product/([A-Za-z0-9-]+)/?$ product.php?product_name=$1 [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
第一条规则将删除所有的空格在一个循环中(使用 [N]
),所以我们不必指定多个的规则集
做一个接一个吧。
The first rule removes all the whitespaces in a loop (using [N]
) so we don't have to specify multiple RewriteRules
doing it one by one now.
下一条规则(与 {ENV:重定向}
状态)是可选的,用来反映在客户端的浏览器使用连字符,以及使所有书签创建链接到网址的正确非whitespaced版本。
The next rule (with {ENV:Redirect}
condition) is optional and is used to reflect the use of hyphens on the client's browser as well so that any bookmarks created link to the correct non-whitespaced version of the URL.