我已经制定了一些规则,例如重定向匹配,以动态指向旧网址到新的位置,但是任何时候我都会在URL编码字符中出现重定向错误,根本不工作。 下面是这些URL的一个示例:网址编码字符不会重新编写的问题
www.example.com/ebc-drama-yebet-sira/yebet-sira-%E1%8B%A8%E1%89%A4%E1%89%B5-%E1%88%B5%E1%88%AB-drama-part-1-video_80c33bc56.html
所以我需要删除像字符: %E1%8B%A8%E1%89%A4%E1%89%B5-%E1%88% B5%E1%88%AB
以上这些字符是等于这个词阿姆哈拉语:የቤት-ስራ
我需要的是一个规则,从URL中删除非字母字符-numerical但保留所有的特殊字符,如“ - “”_“等只是URL编码字符。
我曾尝试:
RewriteRule ^/?(.*)>$ /$1 [L,R=301]
和:
RewriteRule (.*)[^a-zA-Z0-9](.*) $1$2 [N]
的.htaccess文件:
Options -MultiViews
RewriteEngine On
RewriteRule ^index.html$ index.php
RewriteRule ^browse.html$ category.php
RewriteRule ^browse-(.*)-videos.html$ category.php?cat=$1
RewriteRule ^browse-(.*)-videos-([0-9]+)-(.*).html$ category.php?cat=$1&page=$2&sortby=$3
RewriteRule ^videos.flv(.*)$ videos.php$1
RewriteRule ^videos.mp4(.*)$ videos.php$1
RewriteRule ^register.html$ register.php
RewriteRule ^contact_us.html$ contact_us.php
RewriteRule ^edit_profile.html$ edit_profile.php
RewriteRule ^suggest.html$ suggest.php
RewriteRule ^upload.html$ upload.php
RewriteRule ^upload_avatar.html$ upload_avatar.php
RewriteRule ^suggest.html$ suggest.php
RewriteRule ^favorites.html(.*)$ favorites.php$1
RewriteRule ^login.html(.*)$ login.php$1
RewriteRule ^newvideos.html(.*)$ newvideos.php$1
RewriteRule ^topvideos.html(.*)$ topvideos.php$1
RewriteRule ^profile.html(.*)$ profile.php$1
RewriteRule ^user/([^/]+)/?$ user.php?u=$1
RewriteRule ^user/([^/]+)/(.*)/?$ user.php?u=$1&view=$2
RewriteRule ^memberlist.html(.*)$ memberlist.php$1
RewriteRule ^playlists.html(.*)$ playlists.php$1
RewriteRule ^index-([0-9]+).html$ article.php?page=$1
RewriteRule ^browse-(.*)-([0-9]+).html$ article.php?c=$1&page=$2
RewriteRule ^articles/tag/([^/]+)/page-([0-9]+)(/)?$ article.php?tag=$1&page=$2
RewriteRule ^articles/tag/([^/]+)(/)?$ article.php?tag=$1&page=1
RewriteRule ^popular-([0-9]+).html$ article.php?show=popular&page=$1
RewriteRule ^(.*)_([0-9]+).html$ article_read.php?a=$2
RewriteRule ^articles(\/|.html)?$ article.php
RewriteRule ^article(\/|.html)?$ article.php
RewriteRule ^pages/(.*)\.html$ page.php?name=$1
RewriteRule ^playlist/(.*)/([^/]+)(/)?$ watch.php?playlist=$1&vid=$2
RewriteRule ^playlist/(.*)$ playlists.php?playlist=$1
RewriteRule ^tags/([^/]+)/$ tag.php?t=$1&page=1
RewriteRule ^tags/([^/]+)/page-([0-9]+)(/)?$ tag.php?t=$1&page=$2
RewriteRule ^embed/([^/]+)$ embed.php?vid=$1
RewriteRule ^([^/]*)_([a-zA-Z0-9]{9}).html$ watch.php?vid=$2
RewriteRule ^fpembed-(.*).swf$ fpembed.php?vid=$1
RewriteRule ^uploads/thumbs/(.*)-social.(jpg|gif|png)$ social-thumb.php?vid=$1
RewriteRule ^rss.xml$ rss.php [L]
RedirectMatch 301 ^/[\w-]+/([\w-]+\.html)$ /$1
感谢。
对不起,延误@anubhava,实际上这个代码导致css崩溃或网站加载像无限..我必须注意到,正在使用您给我的另一个规则,即:'RedirectMatch 301 ^/[\ w - ] + /([\ w - ] + \。html)$/$ 1'这个老规则也提出了另一个问题,使得其他htaccess文件在其他域中无法正常工作(删除它将修复,但它在主域中正常工作,规则是重要) –
完成后,请查看更新后的问题。 –
评论出'RedirectMatch 301'规则,并将我的给定规则放在'RewriteEngine On'行的下方 – anubhava