我已經制定了一些規則,例如重定向匹配,以動態指向舊網址到新的位置,但是任何時候我都會在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