1. 开启.htaccess文件的支持,打开httpd.conf,一般在/etc/httpd路径下,找到如下内容,并将None改成All:
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
去除下列内容头部的#号
LoadModule rewrite_module modules/mod_rewrite.so
禁止访问某个文件,其中~后面可以跟正则表达式。
<Files ~ "\.xml$">
Order Deny,Allow
Deny from All
</Files>
禁止列出文件列表:
<IfModule mod_autoindex.c>
Options -Indexes
</IfModule>
禁止访问某个目录:
<Directory ~ "^/www/.*/[0-9]{3}">
Order Deny,Allow
Deny from All
</Directory>
重定向:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^bazi/index.html$ /bazi/index.php [L]
RewriteRule ^bazi/detail-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+).html$ /bazi/detail.php?s=$1&y=$2&m=$3&d=$4&h=$5&i=$6 [L]
RewriteRule ^bazi/detail-([0-9]+).html$ /bazi/detail.php?id=$1 [L]
RewriteRule ^m/health-(.+).html /m/health.php?keyword=$1 [L]
RewriteRule index.html index.php
RewriteRule ^artists/$ /artists.php [L]
RewriteRule ^news/$ /news.php [L]
RewriteRule ^browse/$ /browse.php [L]
RewriteRule ^partners/$ /partners.php [L]
RewriteRule ^search/$ /search.php [L]
</IfModule>

发表回复
要发表评论,您必须先登录。