質問

それはURLの末尾にスラッシュが自分であるか否かの動作しますので、

私はそれを作るために、次の書き換えルールに行うためには何が必要ですか?

すなわち。 http://mydomain.com/content/featuredする または http://mydomain.com/content/featured/する

RewriteRule ^content/featured/ /content/today.html 
役に立ちましたか?

解決

0または1回繰り返される前の発現をマークする文字列と$の終わりをマークするために?を使用します。

RewriteRule ^content/featured/?$ content/today.html

しかし、私はあなたが1つの表記に固執し、修正することをお勧めしますスペルミスます:

# remove trailing slashes
RewriteRule (.*)/$ $1 [L,R=301]

# add trailing slashes
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ $0/ [L,R=301]

他のヒント

これを行うための簡単な方法:

RewriteEngine On
RewriteBase / 
RewriteRule ^content/featured(\/||)$ /content/today.html [L,R=301,NC] 
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top