【发布时间】:2013-02-22 20:06:39
【问题描述】:
我正在尝试重写我的网址:
RewriteEngine On
RewriteBase /
RewriteRule ^help/(.+)/(.+) help.php?helpid=$2
RewriteRule ^city/(.+)/(.+) city.php?cityid=$2
即使网址包含预期的格式:http://example.com/help/the-irelevant-title/5/
好像
isset($_GET['helpid'])) 总是会在 help.php 中触发 false
通常这个系统对我有用。我在这里有什么遗漏吗?
-编辑-
我可以看到这应该有效(或至少你们中的一个人回答)我正在向问题添加更多代码:
完整的 .htaccess 内容
RewriteEngine On
ErrorDocument 500 /oohps.php
ErrorDocument 404 /oohps.php
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
RewriteBase /
RewriteRule ^help/([^/]+)/([^/]+) help.php?helpid=$2 [QSA]
RewriteRule ^city/([^/]+)/([^/]+) city.php?cityid=$2 [QSA]
RewriteRule ^login$ login.php
help.php 的开始
session_start();
error_reporting(E_ALL);
ini_set('display_errors', '1');
$_GET['noseo'] = true;
include('htmlhead.php');
/* Leemos la id del grupo*/
$selected;
if(isset($_GET['helpid'])){
$selected = $_GET['helpid'];
}else {
echo '<script>alert("Modrewrite fails. Id is missing, id: '.$_GET['helpid'].'");location.href = "/"</script>'; /* Allways returns this*/
}
【问题讨论】:
-
确保 MultiViews 被禁用,否则 Apache 可能会在不使用 mod_rewrite 的情况下将 /help/ 映射到 help.php
标签: php .htaccess url-rewriting get