htaccess的301重定向和特殊字符问题重定向、特殊字符、问题、htaccess

2023-09-02 09:54:20 作者:酒人

我有结尾的网址

/presentation/Item?k=ZW52aXJvbm1lbnRhbC1oZWFsdGgtc2FmZXR5LXNlY3VyaXR5LWVuZ2xpc2g=&

,我需要重定向到 http://domain.co.uk/films/ehss/

但是,当我用下面的;这是行不通的;我试图逃避特殊字符像?通过将前一个,但仍然没有喜悦。

But when I use the following; it doesn't work; I've tried escaping special characters like the ? by adding a before it but still no joy.

如果它的这是所有被添加到htaccess文件的最开始就一个字preSS网站的任何使用。

If its of any use this is all being added to the very beginning of htaccess file on a wordpress site.

这是我一直想:

Redirect 301 /presentation/Item?k=ZW52aXJvbm1lbnRhbC1oZWFsdGgtc2FmZXR5LXNlY3VyaXR5LWVuZ2xpc2g=& http://domain.co.uk/films/ehss/

我看着看看是否有任何其他字符是特殊字符,它们不是。另外,我不认为我可以使用正则表达式这既可以作为我对50的网址都在相同的格式,上面需要被重定向到搜索引擎友好的URL。

I've looked into see if any of the other characters are special characters and they aren't. Also, I don't think I can use REGEX for this either as I have about 50 urls all in the same format as above that need to be redirected to seo friendly urls.

推荐答案

您可以解析 QUERY_STRING 使用的mod_rewrite

RewriteEngine On

RewriteCond %{QUERY_STRING} ^k=ZW52aXJvbm1lbnRhbC1oZWFsdGgtc2FmZXR5LXNlY3VyaXR5LWVuZ2xpc2g=&$ [NC]
RewriteRule ^presentation/Item$ http://domain.co.uk/films/ehss/? [R=301,L]