.htaccess和php重写
我不能做简单的事情,也不明白是什么问题。 我只想创建一个好看的URL 我的链接如下所示:.htaccess和php重写,php,.htaccess,Php,.htaccess,我不能做简单的事情,也不明白是什么问题。 我只想创建一个好看的URL 我的链接如下所示: www.mysite.com/coach/23/victor 我的.htaccess文件如下所示: RewriteEngine On RewriteRule ^([^/]*)\.html$ /index.php?p=$1 [L] RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?p=$1&id=$2 [L] RewriteRule ^([^/]*)/([^
www.mysite.com/coach/23/victor
我的.htaccess
文件如下所示:
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /index.php?p=$1 [L]
RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?p=$1&id=$2 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /index.php?p=$1&id=$2&title=$3 [L]
$page_type=$_GET['p'];
$page_type=$_GET['id'];
$page_type=$_GET['title'];
在functions.php
文件中,我试图获得如下信息:
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /index.php?p=$1 [L]
RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?p=$1&id=$2 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /index.php?p=$1&id=$2&title=$3 [L]
$page_type=$_GET['p'];
$page_type=$_GET['id'];
$page_type=$_GET['title'];
在index.php
中,我包括functions.php
并进行切换
switch($page_type){
case "home": include "home.php";
break;
}
你没有问任何问题 不过只要分析一下你说的话。你想去吗
www.mysite.com/coach/23/victor
无论您重写的规则是什么,都需要.html
,因此正确的url应该是
www.mysite.com/coach/23/victor.html
答案是否与贪婪的正则表达式有关?谁知道呢。在连续的3行中覆盖
$page\u type
3次可能不会有帮助。错误:找不到请求的URL/coach/135在此服务器上找不到。此外,尝试使用ErrorDocument处理请求时遇到404 Not Found错误。很抱歉,我使用的是:$page_type=$\u GET['p']$id=$\u GET['id']$title=$\u GET['title'];另外一个问题仍然不起作用,重写规则永远不会启动,因为示例链接不包含.html…很抱歉,我对该网站不熟悉,可能没有对所有工作进行正确解释。我可以用这种方式编写链接:www.mysite.com/index.php?p=coach&id=20&title=victor,但它看起来不太好,这就是我想写得更漂亮的原因,但却像一个老林克韦尔。。听到这个消息我很难过,但你到底出了什么问题?没有人能读懂你的心思。设计丢失了,只有没有格式的文本。如果我添加一个链接到这个CSS文件完全返回工作。有没有其他可能?