要求された URL を確認し、要求がファイルに対するものかディレクトリに対するものかに応じて、さまざまなオプションを提供する必要があります。
私の URL は次のようになります。
http://www.example.com/Services/Service-1
(ディレクトリ、サーブ/pages/Services/Service1/index.php
)http://www.example.com/Services/Service-1/Feature-1/Sub-Feature
(実際のファイル、 serve/pages/Services/Service-1/Feature-1/Sub-Feature.php
)
.htaccess を理解していないため (これには RewriteCondition が必要ですか?)、現在、次のようにディレクトリ構造のすべてのフォルダーを列挙するのに行き詰まっています。
RewriteRule ^Services/Service-1/(.*)$ /pages/Services/Service-1/$1.php
RewriteRule ^Services/Service-1 /pages/Services/Service-1/index.php
RewriteRule ^Services/Service-2/(.*)$ /pages/Services/Service-2/$1.php
RewriteRule ^Services/Service-2 /pages/Services/Service-2/index.php
RewriteRule ^Services/(.*)$ /pages/Services/$1.php
RewriteRule ^Services /pages/Services/index.php
RewriteRule ^Testimonials/(.*)$ /pages/Testimonials/$1.php
RewriteRule ^Testimonials /pages/Testimonials/index.php
言うまでもなく、これは本当に面倒です。コンテンツのフォルダーを追加するたびに、.htaccess をいじる必要があります。
もっと良い方法があるに違いないことはわかっていますが、Google と Stackoverflow の検索では、試してみてもうまくいくものは見つかりませんでした。