开发者

htaccess rewritecond for url with asterisks

Some... fine person... has set up an incoming link to our site that looks like: http://www.site.com/*our*-*services*/

I'd like to redirect it so it points it to: http://www.site.com/our-services/

Ours is a Wordpress site so there's some rewrite stuff in our root htaccess file already. A rule that simply removes asterisks from the URL would do, but I can't figure out how to do that, so I tried the following - loosely based on copying the existing Wordpress rules - which isn't working:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} (/\*our\*-\*services\*/)
RewriteRule . /our-services/ [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule开发者_运维问答 . /index.php [L]

</IfModule>

It looks like this rule is being ignored - the errant URL currently redirects you to our default Wordpress 404 page. Clearly, I am fail: what should I have put as the rewrite condition?


I'd remove your first RewriteCond and then just use this rule:

RewriteRule \*our\*-\*services\*\/ /our-services/ [L]


Well get them to change there incoming link.

Asterisks are reserved in urls, so in this case it shouldn't be used:

W3 Url Recommendation

Allowing asterisk in URL

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜