分享一下,punbb论坛不能使用相对网址的问题。

问题:我和论坛同在内网,于是我使用http://192.168.1.6/bbs访问,进入子版面时,坏了,跳到
http://www.tinyun.cn/bbs去了。就因为我的配置文件是$base_url = http://www.tinyun.cn/bbs

好吧,我改为$base_url = "/bbs" 行不?这回更惨,前台没问题,管理界面用不了。
苦恼啊-- : ,明明是内网,偏要我饶一圈公网。

最近苦研PHP,终于找着解决办法了。

解决要点:既然一定要网址,那好吧,你用什么域名访问,我就在/bbs前加你访问的域名。在配置文件里改:
$array = array('http://', $_SERVER["HTTP_HOST"], '/bbs');
$base_url = join($array);

原代码是:
$base_url = http://www.tinyun.cn/bbs

原代码是固定的网址,改成动态获取就行了。

typecho 博客适用,其他未知。

一、Apache


RewriteEngine On
#你的博客目录,可能是/或/blog,用它替换Your_blog_dir,下同
RewriteBase Your_blog_dir
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ Your_blog_dir/index.php/$1 [L]

域名跳转:
带www的跳转到不带的

RewriteCond %{HTTP_HOST} ^www.uqn.cn$
RewriteRule (.*) http://uqn.cn/$1 [R=301,L]

二、Nginx

location / {  #1
index index.html index.php;
if (-f $request_filename/index.html) {
    rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php) {
    rewrite (.*) $1/index.php;
}
if (!-f $request_filename) {
    rewrite (.*) /index.php;  #10
}
}

这个有必要说两句,百度搜到的,几乎全是上面所写,那我的博客目录是/blog的话,就不适用了。怎么办?看着:
把上面#1、#10行改为

根据你的博客路径修改

location /blog {
rewrite (.*) /blog/index.php;

域名跳转:
不带www的跳转到带的

if ($host ~* (blog.|^)(0x84.com)) {
set $without_www $2;
rewrite (.*) http://www.$without_www$1 permanent;
}

三、Lighttpd

文章 | 标签 | 分页 | RSS | 分类 | 归档 | 搜索 | 独立页面

url.rewrite = (
"^/(archives|tag|page|feed|category|[0-9]{4}|search|guestBook.html)(|/.*)" => "/index.php/$1$2",
)

域名跳转:
不带www的跳转到带的

$HTTP["host"] !~ "^(www\.0x84\.com)$" {
url.redirect = ( "^/(.*)" => "%1/$1" )
}

注:请记得到后台永久链接设置里,启用地址重写功能。

1、最简单的

<head>
<meta http-equiv="refresh" content="2;url=/blog/index.php">
</head>

2、PHP

<?php
Header("HTTP/1.1 301 Moved Permanently");
Header("Location:/blog/index.php");
?>

3、.htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.dumiqiu.cn$ [NC]
RewriteRule ^(.*)$ http://www.dumiqiu.cn/$1 [L,R=301]