PHP コーディングに関しては、私がグリーンであることを認めたのは私が初めてです。しかし何年も前に、同僚が PHP と HTML を結合して Web ページを作成するためのパターンを教えてくれました。今、私はサイトを刷新しようとしていますが、より良い書き方があるかどうか知りたいですか? 現在、次のようなレイアウトの index.php ページがあります。
<?php
if (! isset($HTTP_GET_VARS['content']) || ! $HTTP_GET_VARS['content']){
$content="home";
}
else
$content=$HTTP_GET_VARS['content'];
//1
if ($content == "home"){
$page_title="Page Title";
$keywords="Keywords found in Meta";
$desc="Description found in Meta";
$style="scripts/style.css";
$popupjs="none";
$storbutnjs="none";
$retreatjs="none";
$rolloverjs="scripts/rolloverjs.js";
$readform_chkjs="none";
$logo="req-files/logo.html";
$sidebar="req-files/sidebar.html";
$main="home.html";
}
//2
if ($content == "about"){
$page_title="Page Title";
$keywords="Keywords found in Meta";
$desc="Description found in Meta";
$style="scripts/style.css";
$popupjs="none";
$storbutnjs="none";
$retreatjs="none";
$rolloverjs="none";
$readform_chkjs="none";
$logo="req-files/logo.html";
$sidebar="req-files/sidebar.html";
$main="about.html";
}
include ("req-files/head.html");
include ($logo);
include ("req-files/navbar.html");
include ($sidebar);
include ($main);
/*include ("scripts/analytics.js");*/
include ("req-files/footer.html");
?>
したがって、人が入力http://yourwebsite.com/?content=about
すると、必要なすべてのメタ、ヘッダー、サイドバー、フッター、javascript、css、分析などを含む、ブラウザーに組み込まれた About ページ全体が取得されます。これらの必要な部分はそれぞれ html ファイルであり、一部には php スクリプトが含まれる場合があります。ページ タイトル、キーワードなどの一部の $ コールアウトについては、
私の問題の 1 つは、クライアントが「($content == " ")」の 1 つの名前を別の名前に変更したい場合です。まず、変数を変更できますが、ページのランキングが失われないように、古い名前を新しい名前にリダイレクトする必要があります。
たとえば、http://yourwebsite.com/?content=about
にリダイレクトする必要がありますhttp://yourwebsite.com/?content=about-us
。
最終的に、クライアントはすべてまたはほとんどのページをより直接的にリダイレクトしますhttp://yourwebsite.com/about-us
。これにより、サイトを WordPress の Web サイトにする際の再構築がよりスムーズになると考えられます。
それで、これを書くより良い方法はありますか?URL をリダイレクトするより良い方法はありますか?
ありがとうございました...