Add Trailing Slash to the End of the URL with .htaccess Rewrite Rules末尾にスラッシュを追加されたURLの終わりにします。 htaccessのrewriteルール
For a website that has URLs that end with a slash (/), it’sa good practice to ensure that all url links been parsed by the web server ended with trailing slash, even if visitors forget to enter the ending slash.は、ウェブサイトを運営して使用しているの末尾にスラッシュ( / ) 、これは良い練習を確保するため、すべてのURLリンクは、 Webサーバーで解釈され、末尾にスラッシュ終わった場合でも、訪問者を忘れるスラッシュを入力して終了します。 This avoid visitors been served with 404 Page Not Found or Page Cannot be Displayed error as some web servers treat links without trailing slash as a file name instead of directory, and thus unable to locate the documents.このサービスを避けるために訪問者も404ページが見つかりませんまたはページが表示されるエラーが発生することはできませんとして扱うリンクがなく、いくつかのウェブサーバーのファイル名を末尾にスラッシュの代わりとしてディレクトリ、およびそのための文書を見つけることができません。 It also eliminates the possibility that both pages with same content, one with slash at the end and another without, been viewed by search engines as duplicate content.排除する可能性があることも、両方のページと同じコンテンツを、 1つの末尾にスラッシュと別のせず、表示された検索エンジンは、重複したコンテンツです。
As an example, all hits to http://www.mydigitallife.info/contact should be redirect to http://www.mydigitallife.info/contact/.一例として、すべてのヒットをhttp://www.mydigitallife.info/contact http://www.mydigitallife.info/contact/にリダイレクトする必要があります。
Most web server, including the popular Apache HTTPD web server supports mod_rewrite module where rules can be set in .htaccess file in order to redirect to add trailing slash to the URLs that does not already have one.ほとんどのウェブサーバー、ウェブサーバーのhttpdなどの人気のApacheのルールをサポートしてmod_rewriteモジュールのどこで設定できる。 htaccessファイルの末尾にスラッシュを追加するためにリダイレクトされていないのURLを既にお持ちの1つです。
The following code can be put in .htaccess to redirect URL without trailing slash to URL with trailing slash:は、次のコードはに置かれる。 htaccessを使用せずにリダイレクトするURLの末尾にスラッシュを末尾にスラッシュをURL :
RewriteEngine On RewriteEngine on経験上、
RewriteBase / rewritebase /
RewriteCond %{REQUEST_FILENAME} !-f rewritecond % ( REQUEST_FILENAME )の! - f
RewriteCond %{REQUEST_URI} !index.php rewritecond % ( request_uri ) ! index.phpを
RewriteCond %{REQUEST_URI} !(.*)/$ rewritecond % ( request_uri ) !(.*)/$
RewriteRule ^(.*)$ http://domain.com/$1/ [L,R=301] rewriterule ^(.*)$ http://domain.com/ $ 1 / [であるL 、 R = 301 ]
orまたは
RewriteCond %{REQUEST_FILENAME} !-f rewritecond % ( REQUEST_FILENAME )の! - f
RewriteCond %{REQUEST_URI} !\..+$ rewritecond % ( request_uri ) ! \ .. + $
RewriteCond %{REQUEST_URI} !/$ rewritecond % ( request_uri ) ! / $
RewriteRule (.*) http://www.mydigitallife.info/$1/ [R=301,L] rewriterule ( .* ) http://www.mydigitallife.info/ $ 1 / [研究= 301 、左]
orまたは
RewriteEngine On RewriteEngine on経験上、
RewriteBase / rewritebase /
RewriteRule ^([a-zA-Z0-9]+)/$ /$1 [L] rewriterule ^ ( [する座- z0 - 9 ]+)/$ / $ 1 [左]
RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /([a-zA-Z0-9]+) rewritecond % ( the_request ) ^ [アリゾナ] ( 3,9 ) \ / ( [座- z0 - 9 ] + )
RewriteRule ^([a-zA-Z0-9]+)$ /%1/? rewriterule ^ ( [する座- z0 - 9 ] + ) $ / % 1 /ですか? [R=301,L] [研究= 301 、左]
In you’re using CMS or blog such as Wordpress that allows custom URL structure for permalinks, especially for search engine optimization (SEO), the above code should come before the block of rewrite conditions and rules for URL customization for the CMS or blog platform.をお使いのCMSやブログなどのWordPress permalinksを使用することができるカスタムURLの構造を、特に検索エンジン最適化( SEO )は、上記のコードブロックの前に来る必要条件とのルールを書き換えるのURLやブログのカスタマイズは、プラットフォームのCMSです。
Brief explaination of the rewrite code to add trailing slash to URL 簡単な説明を書き換えるコードをURLの末尾にスラッシュを追加する
RewriteEngine On - This line enables the runtime rewriting engine based on mod_rewrite module of Apache. RewriteEngine on経験上、 -この行に基づいて書き換えエンジンを使用すると、ランタイムはm od_rewriteモジュールのA pacheです。
RewriteBase / - This line sets the current page root directory as base URL for per-directory rewrites. rewritebase / -この行セットをベースとして、現在のページのルートディレクトリのU RLを1ディレクトリに書き換えた。
RewriteCond %{REQUEST_FILENAME} !-f - This line excludes all URLs pointing to existed files from been added with trailing slash again. rewritecond % ( REQUEST_FILENAME )の! - f -この行を除くすべてのU RLからのファイルの存在を指して、末尾にスラッシュを再度追加されました。 Directories cannot be excluded as this would exclude the rewrite behavior for existing directories.ディレクトリを除外することはできませんこれは除外するとして、既存のディレクトリを書き換えるの動作をします。
RewriteCond %{REQUEST_URI} !index.php - This line is optional, and will excludes a sample URL (in this case, index.php) that users do not want it to be rewritten. rewritecond % ( request_uri ) ! index.phpを-この行は任意ですが、除外するとサンプルU RL(この場合、 i ndex.phpを)を利用しない場合はそれを書き直したものです。 Remove this line if not necessary.この行を削除していない場合は必要です。
RewriteCond %{REQUEST_URI} !\..+$ - Specify that the URL does not contain any . rewritecond % ( request_uri ) ! \ .. + $ -指定するには、任意のU RLが含まれていません。 (dot) to exclude reference to file. (ドット)を除外するファイルの参照をします。
RewriteCond %{REQUEST_URI} !(.*)/$ - This line determines which URL doesn’t contain a trailing slash rewritecond % ( request_uri ) !(.*)/$ -この行を決定どのようなU RLの末尾にスラッシュが含まれていません
RewriteRule ^(.*)$ http://www.domain.com/$1/ [L,R=301] - This line process URL without trailing slash that has passed conditions set above, by appending a trailing slash and then redirect with 301 or permanent redirect status to the new URL. rewriterule ^(.*)$ http://www.domain.com/ $ 1 / [であるL 、 R = 301 ] -この行プロセスのU RLに末尾にスラッシュの条件を設定して渡されるように、末尾にスラッシュを付け加えると入力し、リダイレクトに301または新しいURLの状態を恒久的にリダイレクトします。 L mean this is the last line to process and the rewrite process can be terminated.これは、左の最後の行に意味を処理すると書き換えプロセスが終了します。 Remember to replace the www.domain.com with your own domain name. www.domain.comに置き換えるのを忘れないで、独自のドメイン名を入力します。
Brief explaination for second set of rewrite rules and rule conditions 簡単な説明を書き換えるルールやルールセットの2番目の条件
RewriteRule ^([a-zA-Z0-9]+)/$ /$1 [L] - This line terminates the trailing slash appending rewrite process if the URL already contains trailing slash. rewriterule ^ ( [する座- z0 - 9 ]+)/$ / $ 1 [左] -この行の末尾にスラッシュ付け加える書き換えプロセスが終了する場合は、末尾にスラッシュのU RL既に含まれています。
RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /([a-zA-Z0-9]+) - This line determines request that does not ends with trailing slash. rewritecond % ( the_request ) ^ [アリゾナ] ( 3,9 ) \ / ( [座- z0 - 9 ] + ) -この行を要求されていないと判断末尾にスラッシュで終わる。
RewriteRule ^([a-zA-Z0-9]+)$ /%1/? rewriterule ^ ( [する座- z0 - 9 ] + ) $ / % 1 /ですか? [R=301,L] - This line append a slash to the end of URI and perform a 301 permanent redirect to the new URL with trailing slash, and terminate the rewrite block. [研究= 301 、左] -この行の末尾にスラッシュをヨルリンウリの終わりに恒久的にリダイレクトされる3 01を実行すると、新しいU RLに末尾にスラッシュ、および終了して書き換えるブロックします。
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. 重要 :これは、機械翻訳ページで提供"現状有姿"を保証します。 Machine translation may be difficult to understand.機械翻訳を理解するのは難しいかもしれません。 Please refer toを参照してください original English articleオリジナルの英語記事索引 whenever possible.いつ可能です。
Share and contribute or get technical support and help atを共有して貢献や技術サポートとヘルプを得る My Digital Life Forums 私のデジタルライフフォーラム .です。
Related Articles関連記事
- Redirect or Rewrite to Remove Double or Multiple Slashes (//) in URL書き換えを削除するにリダイレクトまたはダブルまたは複数のスラッシュ( / / )でのURL
- SEO Friendly Rewrite Method to Move Website URL From Subdirectory to Root Parent Folderソフレンドリー書き換えるメソッドのサブディレクトリに移動するウェブサイトのURLから親フォルダをルート
- Remove and Uninstall or Disable ModSecurity (mod_security)を削除し、アンインストールまたは無効にmodsecurity (のmod_security )
- WordPress Permalinks Does Not Work in xampp Setup WordPress PermalinksはXAMPPのセットアップが機能しない
- Remove or Trim First or Last Few Characters in MySQL Database with SQLトリム削除したり、最初または最後の数文字をMySQLデータベースをSQL
- How to Move WordPress Blog to New Domain or Location WordPressのブログに移動する方法を新しいドメインまたは場所
- Fix Session Save Path Red Unwritable When Installing Joomla!修正プログラムのインストール時にセッションデータ保存パスを書くことのできない赤joomla !
- How to Add a MySpace User As Friend in Friends List MySpaceのユーザーを追加する方法としての友達が友達リスト
- How to Activate and Use FeedBurner MyBrand for Free Feedburnerの使用を有効にする方法を無料でmybrand
- How to Add and Put Picture or Image in MySpace Commentどのように写真や画像を追加して、 myspaceのコメント















July 26th, 2008 05:19 2008年7月26日05:19
[...] Ä Ãm predÃdete aj problému Ä .2. [...] predãdeteのAJ problã ©ムーãm ä ä .2 。 Pre htaccess som naÅ¡iel pekný, ale anglický Ä lánok o tom, how to add trailing slash to the end of the URL. htaccessのサウンドiel peknã事前naå ¡ ½ 、エールlã ¡ ä ½ anglickãノルウェークローネまたはトムは、末尾にスラッシュを追加する方法を終わりにしてください。 Možnosti máte [...] moå ¾ nosti mã ¡ te [...]