如何解决Reddit Like 子文件夹重定向
示例
LIKE
实际上是在向我们展示
http://www.reddit.com/r/example
一直在浏览器 URL 栏中显示 http://www.reddit.com/r/example。我知道这涉及 .htaccess,但是每次我想到如何在 google 上搜索解释时,它确实向我展示了与我的意思完全不同的解释,所以我深表歉意,因为我确定有人问过这个问题之前。
解决方法
您的 .htaccess
文件应该是这样的:
# Do not remove this line or mod_rewrite rules and search engine friendly URLs will stop working
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^(.+)$ index.php?p=$1 [QSA,L]
示例 index.php
,请记住将您的页面存储在名为 pages
的地图中
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Document</title>
</head>
<body>
<?php
if(isset($_GET['r'])){
if(file_exists('pages/' . $_GET['r'] . '.php')){
include'pages/' . $_GET['r'] . '.php';
}
else{
echo 'This page does not exist';
}
}
else{
include'pages/home.php';
}
?>
</body>
</html>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。