从旧的漂亮网址中删除字符,httpd/htaccess

remove characters from old pretty urls, httpd/htaccess

我最近更新了一个旧博客。旧的博客posts 有不好的(旧的)urls 被搜索引擎索引。我现在正在创建更好的,但因此在 Google 网站管理员中被骗了。

我用 rewriteRule 解决了大部分问题,但我仍然卡在问号、感叹号和圆点等特殊符号上。

我已经尝试了这里其他线程中建议的几乎所有片段,但没有成功...

问题是这样的:

我有一个旧博客 post url:

http://example.com/blog/username/thank-god?-its-friday!!!._b-37483.html

我在博客上更新代码后,系统现在吐出:

http://example.com/blog/username/thank-god-its-friday_b-37483.html

上面的两个链接都有效,我在 Google 中得到了重复的内容。

如何删除“?”、“!”、“.”在 httpd.conf(或 htaccess)中以正确的方式?

下面是我在 httpd.conf 中涉及重写的代码

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^.*$ http://example.com%{REQUEST_URI} [R=301,L]
RewriteRule ^sitemap.xml$ sitemap.php [L]
RewriteRule ^(.*)ä(.*)$ /a [L,R=301]
RewriteRule ^(.*)å(.*)$ /a [L,R=301]
RewriteRule ^(.*)ö(.*)$ /o [L,R=301]
RewriteRule ^(.*)Å(.*)$ /a [L,R=301]
RewriteRule ^(.*)Ä(.*)$ /a [L,R=301]
RewriteRule ^(.*)Ö(.*)$ /o [L,R=301]
Rewriterule ^blog/(.+)/(.+).html$       ./blog/view/blog.php?page=&mode= [NC]
Rewriterule ^blog/(.+).html$            ./blog/blog.php?page= [NC]
Rewriterule ^blog/(.+)/$                ./blog/view/blog.php?page= [NC]
Rewriterule ^blog/$                     ./blog/blog.php [NC]
RewriteCond %{REQUEST_FILENAME} !-f
Rewriterule ^blog/(.+)/(.+)$        ./blog/view/blog.php?page=&mode= [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^blog/(.+)$ ./blog/blog.php?page= [NC]
RewriteRule ^([A-Za-z0-9\-\+]+)$ ./artiklar.php?p= [L]

您可以尝试在 RewriteEngine On

下方添加此内容
RewriteRule ^(.*/)([^/]*)[^/A-Za-z0-9_-]+([^/]*\.html)$ / [L,R=301]

清除所有不需要的字符。