1

私はワードプレスのウェブサイトに取り組んでいます。URLに存在しない場合、ウェブサイトのURLの最後にスラッシュを追加したい。

この url に対するいずれかの要求が :www.mydomain.com/page/subpageである場合、実用的に変換されwww.mydomain.com/page/subpage/ます (url の末尾にスラッシュを追加します)。ユーザーが www.mydomain.com/page/subpageURLを要求すると、URLが見つからないというエラーが表示されるため、これが必要です。

URL の書き換えには、web.configファイルで次のルールを使用します。

web.config ルール:

<rule name="Add trailing slash" stopProcessing="true">  
  <match url="(.*[^/])$" />  
  <conditions>  
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />  
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />  
  </conditions>  
  <action type="Redirect" redirectType="Permanent" url="{R:1}/" />  
</rule>

前もって感謝します。

4

1 に答える 1

-2

これを試して

例 – 末尾にスラッシュがないすべての URL を、末尾にスラッシュがある URL にリダイレクトする

.htaccess 書き換えルールを作成する

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !example.php
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ http://domain.com/$1/ [L,R=301]
于 2013-10-29T06:45:37.250 に答える