2017-01-01 4 views
1

リダイレクトのようないくつかのルールを作成して、古いURLを新しい場所に動的にポイントします。 URL内のURLエンコードされた文字で、まったく働いていません。ここ は、それらの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 

感謝を。

答えて

0

ここ をあなたのルールをテストすることができますあなたのサイトのルートの.htaccessにこれらのルールを使用することができます

[^a-zA-Z0-9-_./] 

をお試しください:

RewriteEngine On 

# skip all css/js/images from rewrite rules below 
RewriteRule \.(?:jpe?g|gif|bmp|png|ico|tiff|css|js)$ - [L,NC] 

RewriteCond %{REQUEST_URI} !^/(admin|articles?|user|tags|embed|playlist|uploads)(/.*)?$ [NC] 
RewriteRule ^(.*)[^\w/.-]+(.*\.html)$ $1$2 [DPI,N,E=SP:1] 

RewriteCond %{ENV:SP} =1 
RewriteRule ^[\w.-]*$ /$0 [L,R=302,NE] 

# comment out RedirectMatch 301 rule 

# remaining RewriteRule appear here 

これはにより/ebc-drama-yebet-sirayebet-sira---drama-part-1-video_80c33bc56.html/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をリダイレクトしますすべての特殊文字を削除します。

+0

遅れて申し訳ありません@anubhava、実際にこのコードは、CSSがクラッシュするか、無限にロードするようにウェブサイトを引き起こしました。あなたが私に与えた別のルールを使用していることに気づく必要があります: 'RedirectMatch 301 ^/[\ w - ] + /([\ w - ] + \ .html)$/$ 1'また、この古い規則は、他のドメインへのポンティングを行っているサブディレクトリ内の他のhtaccessファイルを機能させないという別の問題を引き起こしています(削除するとそれを修正しますが、重要) –

+0

それは完了です。更新された質問を見てください。 –

+0

'RedirectMatch 301'ルールをコメントアウトして、' RewriteEngine On'ラインのすぐ下に配置します。 – anubhava

0
+0

http://martinmelin.se/rewrite-rule-tester/ –

+0

%を追加すると、URLは%文字を保持してリダイレクトされません。 http://martinmelin.se/rewrite-rule-tester/ –

+0

あなたは正しいです...上記の私の答えを編集..これは、すべての%を削除しますが、 - と_を保持します/ – Tina

関連する問題