2016-07-31 68 views
0

我错误地创建了包含点的URL。为了更新点“ - ”我已经更新了数据库中的所有网址,同时我添加了下面一行到我的.htaccess包含点的URL重定向

# Don't rewrite any URIs ending with a file extension (ending with .[xxxx]) 
RewriteCond %{REQUEST_URI} !\.[a-zA-Z0-9]{2,5}$ 

现在有没有什么办法,我可以在添加重写规则或条件.htaccess以便所有包含点的URL都可以通过用' - '替换点来重定向?

回答

0

是的,这很简单。您所使用的所有内容在使用捕获组的.之前和之后匹配,然后仅使用backrefences创建带有-的新URL。

RewriteCond %{REQUEST_URI} ^/(.+)\.(.+)$ [NC] 
RewriteRule^/%1-%2 [R=301,L] 

让我知道如何工作了