Archive for December, 2014

网站虚拟主机域名访问绑定和301跳转.htaccess伪静态规则301重定

.htaccess这个模块是apache的一个算是叫扩展示模板吧要能让它可以运行必须在RewriteEngine让下面的rewrite功能打开或关闭on是打开off是关闭,可以的

重定向老域名.com到www.新域名.com.

 

代码如下复制代码

RewriteEngine On
RewriteCond %{HTTP_HOST} !老域名.com$ [NC]
RewriteRule ^(.*)$ http://www.新域名.com/$1 [L,R=301]

重定向老域名.com to 新域名.com

代码如下复制代码

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !老域名.com$ [NC]
RewriteRule ^(.*)$ http://新域名.com/$1 [L,R=301]

重定向domain.com/file/file.php 到 otherdomain.com/otherfile/other.php

代码如下复制代码

RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^file/file.php$ http://www.otherdomain.com/otherfile/other.php [R=301,L]

RewriteBase /news
RewriteCond %{HTTP_HOST} ^www.111cn.net [NC]
RewriteRule com(.*)$ http://www.111cn.net$1 [L,R=301]

#不加斜杠请求的地址是/wwwroot/www.111cn.net/news/

代码如下复制代码

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

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

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

# 修改以下语句中的 /discuz 为你的论坛目录地址如果程序放在根目录中请将 /discuz 修改为 /
RewriteBase /

# Rewrite 系统规则请勿修改

代码如下复制代码

RewriteCond %{HTTP_HOST} !^www.111cn.net$ [NC]
RewriteRule ^(.*)$ http://www.111cn.net/$1 [L,R=301]
RewriteRule ^archiver/((fid|tid)-[w-]+.html)$ archiver/index.php?$1
RewriteRule ^forum-([0-9]+)-([0-9]+).html$ forumdisplay.php?fid=$1&page=$2
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+).html$ viewthread.php?tid=$1&extra=page%3D$3&page=$2
RewriteRule ^space-(username|uid)-(.+).html$ space.php?$1=$2
RewriteRule ^tag-(.+).html$ tag.php?name=$1

[NC]:no case的缩写意思是忽略大小写a-z和A-Z是没有差别的
[NC,OR]:OR=AND意思是此句要紧接着下一句语法
[R=301,L]:R=301redirect的缩写意思是用301永久转向(当网址在上述名单内就自动转向至你指定的网址)LLast的缩写意思是最后一句了

Komentarji

Linux下使用parted分区工具为大于2T硬盘分区

目的在centos 5.4系统下用parted功能分区12T的硬盘并格式化成ext4,12T共分为2个分区一个7.5T,另一个4.5T.
在linux 下大磁盘的分区不能再采用fdisk了MBR分区表只支持2T磁盘所以大于2T的磁盘必须使用GPT分区表下面说明下具体的步骤:
1.分为两个主分区

 

[root@localhost ~]# parted /dev/sdb # 使用parted来对GPT磁盘操作进入交互式模式
GNU Parted 1.8.1 Using /dev/sdb Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) mklabel gpt # 将MBR磁盘格式化为GPT
(parted) print #打印当前分区
(parted) mkpart primary 0 4.5TB # 分一个4.5T的主分区
(parted) mkpart primary 4.5TB 12TB # 分一个7.5T的主分区
(parted) print #打印当前分区
(parted) quit 退出
Information: Don’t forget to update /etc/fstab, if necessary.

 

2.然后格式化成ext4,需要安装包e4fsprogs.x86_64(yum install e4fsprogs.x86_64)Za

[root@localhost ~]# mkfs.ext4 /dev/sdb1
[root@localhost ~]# mkfs.ext4 /dev/sdb2

 

3.接着用mount挂载分区

[root@localhost]# mount -t ext4 /dev/sdb1 /bk
[root@localhost]# mount -t ext4 /dev/sdb2 /mail
[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda6 ext3 39G 9.4G 28G 26% /
/dev/sda1 ext3 122M 13M 103M 12% /boot
none tmpfs 1004M 0 1004M 0% /dev/shm
/dev/sdb1 ext4 4.1T 194M 3.9T 1% /bk
/dev/sdb2 ext4 6.8T 179M 6.4T 1% /mail

 

4.最后修改/etc/fstab添加如下两行让其开机自动挂载.

/dev/sdb1 /bk ext4 defaults,noatime 1 2
/dev/sdb2 /mail ext4 defaults,noatime 1 2

 

Komentarji