【发布时间】:2018-11-05 03:01:45
【问题描述】:
我们可以使用 htaccess 显示这样的 url
http://www.example.com/group/goroupName
我在pages 文件夹中有group.php 文件。我想显示上面的网址。
这个规则我试过了
RewriteRule ^group/([\w-]+)/?$ pages/group.php?group_username=$1 [L,QSA]
但某些包含的 php 文件未显示。例如:
<?php
include_once '../../functions/includes.php';
if(isset($_GET['group_username'])) {
$group_username=$_GET['group_username'];
include_once '../../functions/includes/get_group.php';
if(empty($group_profile_owner_id)){
header("Location:$url404");
}
}else{
header("Location:$url404");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="theme-color" content="#8e24aa">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<title><?php echo $group_username;?></title>
<?php include("../../themes/$getTemplate/contents/style_js.php");?>
</head>
<body>
在上面的代码中,这包括不显示:
<?php include("../../themes/$getTemplate/contents/style_js.php");?>
我的RewriteRule有什么问题
【问题讨论】:
-
您能否提供更多信息,关于未显示的文件是什么?如果我理解您的问题,您可以找到解决方案here
-
@CharfiOmar 谢谢你的回答。我刚刚添加了未显示文件的示例。
-
@anubhava 我确实尝试过,但当时几乎是同样的问题。
-
@anubhava 因为它是全局文件,所有
css,js文件都在style_js.php文件中我只是在这里用style.css写一个例子 -
@anubhava 现在它正在工作,这意味着我的
RewriteRule是正确的,对吧?
标签: .htaccess