PHP 擬似静的 URL 書き換えの簡単な例

WBOY
リリース: 2016-07-25 08:59:45
オリジナル
1091 人が閲覧しました
  1. RewriteEngine on
  2. RewriteRule ^article/index.html$article/index.php
  3. RewriteRule^article/detail-(.[0-9]*).html$article/index.php?type=detail&id= $1
  4. RewriteRule ^article/list-(.[0-9]*)-(.[0-9]*).html$article/index.php?type=list&classid=$1&offset=$2
  5. RewriteRule ^product/index .html$ product/index.php
  6. RewriteRule ^product/detail-(.[0-9]*).html$ product/index.php?type=detail&id=$1
  7. RewriteRule ^product/list-(.[0- 9]*)-(.[0-9]*).html$ product/index.php?type=list&classid=$1&offset=$2
  8. RewriteRule ^index.html$index.php
  9. RewriteRule ^aboutus/detail-(. [0-9]*).html$ aboutus/index.php?type=detail&id=$1
  10. RewriteRule ^aboutus/detail-(.[0-9]*)-(.[0-9]*).html$ aboutus/index.php?type=list&classid=$1&offset=$2
复制代

说明: aboutus、article、product は模倣名です。

  1. RewriteRule ^aboutus/detail-(.[0-9]*)-(.[0-9]*).html$ aboutus/index.php?type=list&classid=$1&offset=$2
二重生成コード

これは私たちのモジュール分に関するものです。 RewriteRule ^index.html$index.php是首页伪静态重写 静的動作が必要なモジュールがある場合は、上記の .htaccess ファイルの書き込みを参照してください。

2、Web サイトの後段へのシステム管理 — 構成管理 — には、静的なモジュール接続モードを 2 に変更する必要がありますが、その他の変更は必要ありません。

3、上面の地面を再書き込みした後、静的な地盤、上面の aboutus/detail-(.[0- 9]*).html 、ここの (.[0-9]*) を 1 に変更し、静的アドレスに変更するのはこのように aboutus/detail-1.html で 1 つの接続モードを追加することもできます。

4、記事モジュールのように保存を解除し、先頭のアドレスも記事項目にし、何も変更せずに記事モジュールを開き、その後、文章の接続が表示されるようにします。 注意: .htaccess を握った場合、ルート目録に放り出されてネットワークが開かない等のエラーが発生した場合、環境が原因である可能性があるため、.htaccess ウェブサイトは正常に開くことができます。

ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!