开发者

htaccess rewritecond for url with asterisks

开发者 https://www.devze.com 2023-03-17 14:05 出处:网络
Some... fine person... has set up an incoming link to our site that looks like: http://www.site.com/*our*-*services*/

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

精彩评论

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

关注公众号