0

からいくつかのURLを書き直したかった

www.example.ro/women_shoes.php から www.example.ro/women-shoes/ へ、ページ付けをすると www.example.ro/women_shoes.php?page=1 から www.example.ro/women_shoes/pagina-2 のようになります/

www.example.ro/men_shoes.php から www.example.ro/men-shoes/ へ、最初のようなページネーションで

www.example.ro/sandale_barbati.php から www.example.ro/sandale-barbati/ など..

私が試した最後の例について

RewriteRule ^sandale-barbati/pagina-([0-9]+)/ /sandale-barbati.php?page=$1 [L]
RewriteRule ^sandale-barbati/?$ /sandale_barbati.php?$

しかし、私はすべてのページにそれを書く必要があります...すべてのページに対して自動的にそれを行う方法はありますか?

ありがとう

4

1 に答える 1

1

すべてのページで常に同じ名前を使用している場合、これは機能します。

RewriteRule ^([a-zA-Z]+)([-_]){1}([a-zA-Z]+)/pagina-([0-9]+)/$ $1_$3.php?page=$4
RewriteRule ^([a-zA-Z]+)([-_]){1}([a-zA-Z]+)/$ $1_$3.php
RewriteRule ^([a-zA-Z_]+)/pagina-([0-9]+)/$ /$1.php?page=$2
RewriteRule ^([a-zA-Z_]+)/$ /$1.php

You can surf to /women_shoes/ and it will be the /women_shoes.php page.
You can surf to /women-shoes/ and it will be the /women_shoes.php page.
You can surf to the /shoes/ and it will be the /shoes.php page.

これがすべての要件を満たし、十分に役立つことを願っています。今後の参考のために、Web サイトhttp://www.regular-expressions.info/は、正規表現 (.htaccess 書き換えルールなど) を扱うときに非常に便利です。

于 2012-08-11T14:26:12.987 に答える