Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2914824
  • 博文数量: 454
  • 博客积分: 4860
  • 博客等级: 上校
  • 技术积分: 6375
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-13 10:08
个人简介

10年工作经验,专研网站运维。

文章分类

全部博文(454)

文章存档

2017年(11)

2016年(13)

2015年(47)

2014年(36)

2013年(147)

2012年(64)

2011年(136)

分类: LINUX

2011-09-11 14:34:14

网站需要伪静态功能,基本上所有的网站都需要伪静态功能,今天弄了一上午,终于弄明白了。
1、安装的时候
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-ssl
这时apache已经拥有的伪静态功能了,称为内建伪静态。
2、如果安装的时候没有  --enable-rewrite  这个参数,那么:
到“LoadModule” 区域,在最后一行加入“LoadModule rewrite_module modules/mod_rewrite.so”(必选独占一行),然后重启apache服务器即可。
3、让apache服务器支持.htaccess
vim /usr/local/apache2/conf/extra/http-vhosts

Options FollowSymLinks

AllowOverride None

改为

Options FollowSymLinks

AllowOverride All

就可以了。
但是需要在网站文件中加入一个htaccess文件。才可以综合支持伪静态功能。(在网站文件目录下)
vim .htaccess
RewriteEngine On
RewriteBase /
# Rewrite规则

RewriteRule ^index\.htm$ index\.php

RewriteRule ^jobs/jobs-show-([0-9]+)\.htm$ jobs/jobs-show\.php\?id=$1

RewriteRule ^company/company-show-([0-9]+)\.htm$ company/company-show\.php\?id=$1

RewriteRule ^resume/resume-show-([0-9]+)\.htm$ resume/resume-show\.php\?id=$1

RewriteRule ^news/news-list-([0-9]+)-([0-9]+)\.htm$ news/news-list\.php\?id=$1&page=$2
RewriteRule ^news/news-show-([0-9]+)\.htm$ news/news-show\.php\?id=$1

RewriteRule ^explain/explain-show-([0-9]+)\.htm$ explain/explain-show\.php\?id=$1

RewriteRule ^notice/notice-list-([0-9]+)-([0-9]+)\.htm$ notice/notice-list\.php\?id=$1&page=$2
RewriteRule ^notice/notice-show-([0-9]+)\.htm$ notice/notice-show\.php\?id=$1
这个文件应该是程序编的,与我没有关系。

伪静态报错:
主站好用,但是链接不好用。链接是一个静态页面。以.html结尾的,所以我判断,就是为静态页面没生效,所以就添加.htaccess文件即可。
阅读(1754) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~