我的頁面上有幾個簡單的聯繫表單。 直到我添加了這個.htaccess文件,所有的工作都很好(表單已發送到腳本中的電子郵件)。PHP表單與.htaccess衝突
有沒有辦法處理PHP表單,同時還包括.htaccess文件? (因爲它使網站看起來非常好)
在此先感謝。
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase/
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule^%1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule^%{REQUEST_URI}.php [L]
表單代碼:
<?php
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$from = 'From: Contact Page';
$to = '[email protected]';
$subject = 'Contact Page';
$human = $_POST['human'];
$body = "From: $first_name\n $last_name\n E-Mail: $email\n Phone: $phone\n Message:\n $message";
if ($_POST['submit'] && $human == '4') {
if (mail ($to, $subject, $body, $from)) {
header('Location: http://www.xxxxxx.com/ThankYou.php');
exit();
} else {
header('Location: http://www.xxxxxx.com/error.php');
}
} else if ($_POST['submit'] && $human != '4') {
header('Location: http://www.xxxxxx.com/error.php');;
}
?>
是什麼形式的動作我以前的答案嗎?爲什麼你不知道你在做什麼而添加一個服務器配置? – donald123
你可以添加表單代碼嗎? – versalle88
表單正在發佈。我添加了它,因爲我知道我想要它做什麼;)(這是爲了使網址很好)如果我總是知道我在做什麼,我什麼都不會做;) – newneub