1.404跳转:
vi /etc/httpd/conf/httpd.conf
在虚拟主机配置里添加一行:ErrorDocument 404 /404.html
2.301跳转:
1)将不带www的跳转到带www的:在根目录下新建.htaccess文件,写入:
Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^manyi.cc [NC] RewriteRule ^(.*)$ http://www.manyi.cc/$1 [L,R=301]
2)重定向到新域名:
Options +FollowSymLinks RewriteEngine on RewriteRule ^(.*)$ http://www.manyi.cc/$1 [L,R=301]
3)在httpd.conf配置文件中配置:
<VirtualHost *:80> ServerName manyi.cc RedirectMatch permanent ^/(.*) http://www.manyi.cc/$1 </VirtualHost>
3.使用正则进行301伪静态配置:(将news.php?id=123这样的地址转向到news-123.html)
Options +FollowSymLinks RewriteEngine on RewriteRule ^news-(.+)\.html$ news.php?id=$1
时间: 2024-11-03 03:31:44