このトピックに関する複数のスレッドを確認しましたが、それらはすべて複数のパラメーターを扱っており、.htaccess を初めて使用したため、必要なものに合わせて回答を変更する方法を理解できませんでした。
.htaccess を使用して URL を書き換えていますが、ページネーション URL を書き換えてみた以外はすべてうまくいっているようです。
私のページネーション URL は非常に単純です: blog.php?page=2 ですが、何らかの理由で URL を /blog/page/2 に書き換えることができません。その URL にルーティングしようとすると、「内部サーバー エラー」が発生します。現在、/blog-page/2 に書き直していますが、/blog/page/2 にしたいと考えています。
私は .htaccess ファイルで多くのことを行っているので、書き直しのみを投稿します。
RewriteEngine On
# Full path
#RewriteBase /
# Rewrite all php files
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
# Rewrite the user profile pages
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^user/([a-zA-Z0-9_-]+)$ profile.php?user=$1
RewriteRule ^user/([a-zA-Z0-9_-]+)/$ profile.php?user=$1
# Rewrite the company profile pages
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^company/([a-zA-Z0-9_-]+)$ employer.php?user=$1
RewriteRule ^company/([a-zA-Z0-9_-]+)/$ employer.php?user=$1
# Rewrite the blog post pages
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^post/([a-zA-Z0-9_-]+)$ entry.php?id=$1
RewriteRule ^post/([a-zA-Z0-9_-]+)/$ entry.php?id=$1
# Rewrite the job listing pages
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^job/([a-zA-Z0-9_-]+)$ listing.php?id=$1
RewriteRule ^job/([a-zA-Z0-9_-]+)/$ listing.php?id=$1
# Rewrite blog pagination
RewriteRule ^blog/page/([0-9]+)$ blog.php?page=$1
RewriteRule ^blog/page/([0-9]+)/$ blog.php?page=$1
明らかに、私が抱えている問題は、ブログのページネーションの最終的な RewriteRule にあります。/blog/page/2 にできないのに、/blog-page/2 にできるのはなぜですか?
また、ブログ カテゴリとジョブ カテゴリに対して複数ページの .htaccess 書き換えを実行しようとしていますが、内部エラーが発生し続けます。ブログの職種とブログのカテゴリーを1回書き直してほしいです。そのために私が持っているものは次のとおりです。
# Rewrite the category queries
RewriteRule ^/category/(.*)/?$ /$.php?cat=$1 [L,QSA]
このページネーションの書き換えを 2 つの異なるページで機能させることは可能ですか? blogs.php や jobs.php など?
RewriteCond %{REQUEST_FILENAME} !-f
また、書き換えルールを作る前に を入れ続ける必要はありますか?それとも1回で十分ですか?