【发布时间】:2017-03-03 16:06:23
【问题描述】:
在索引页面中,我是下面的 html 表单:
<form id="formname" class="form-inline" role="form" method="get" action="<?php echo htmlspecialchars(SITE_URL.'location'); ?>">
</form>
在此页面中,我有以下 js 脚本:
$("#formname").submit(function(event) {
event.preventDefault();
var loc = $("#basic option:selected").text();
window.location.href = url+ loc;
});
提交此表单后,网址如下所示:
从这个页面:我点击这个网址:menu-details?mid=2
我希望这个网址应该是
从这个页面我点击这个 url:booking 页面(这是一个 booking.php 页面)
从此页面我使用$_POST 方法获取表单名称和值,但我希望url 看起来像这样:(然后我将使用$_GET 方法)
`
http://localhost/freelancer/chef/california/2/menuname/booking
目前我正在使用以下 .htaccess 规则,但它仅适用于第一个 url 而不是我想要的所有 url。
.htaccess
ErrorDocument 404 /freelancer/chef/not-found.php
ErrorDocument 500 /freelancer/chef/not-found.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9_-]+)$ city.php?city=$1 [NC,L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
更新:
ErrorDocument 404 /freelancer/chef/not-found.php
ErrorDocument 500 /freelancer/chef/not-found.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9_-]+)/?$ city.php?city=$1 [NC,L]
#RewriteRule ^([A-Za-z0-9_-]+)/([\d]+)/([A-Za-z0-9_-]+)$ menu-details?mid=$2 [NC,L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ menu-details.php?city=$1&mid=$2&title=$3
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
【问题讨论】:
标签: php .htaccess mod-rewrite seo