投稿日:2017/12/21
/contact.html
となっているページにフォームを設置する場合。被リンクがあるはずなので、ページ名は変更したくない。抜けも怖いし。
そんなとき。
.htaccessでリライトをかける
確認画面等も考慮する必要があるので、以下のように3行必要<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^contact\.html$ contact/index.php [L]
RewriteRule ^confirm\.html$ contact/confirm.php [L]
RewriteRule ^submit\.html$ contact/submit.php [L]
</IfModule>
フォームのHTMLを書き換える
送信や戻るボタンが.php
表記のままなので、.html
に変更しよう。
view/form.php
13行目
<form method="post" action="confirm.html" class="inquiry h-adr">
view/confirm.php
7行目
<form method="post" action="submit.html" class="inquiry h-adr">
33行目
<button type="button" class="button cancel" onclick="location.href='./contact.html<?= '?PHPSSID='.session_id(); ?>';">修正する</button>