Home > Backend Development > PHP Tutorial > .htaccess伪静态有关问题

.htaccess伪静态有关问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 12:19:09
Original
1174 people have browsed it

.htaccess伪静态问题
.htaccess伪静态问题

RewriteEngine on
Rewritebase /
ErrorDocument 404 /404.html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?domain=$1 [QSA,PT,L]

我一直用这个,这个有个缺点是什么文件都给包含进去了

比如你访问whois.hangye5.com/womai.cn
这样是可以的
但是如果访问whois.hangye5.com/sitemaps/sitemap1.html
也会跑到index.php文件里去
我想这二个文件不要都跑index.php里去,要修改哪些
------解决思路----------------------
#当目录存在时不做重写
RewriteCond %{REQUEST_FILENAME} !-d

#当文件存在时不做重写
RewriteCond %{REQUEST_FILENAME} !-f

whois.hangye5.com/sitemaps/sitemap1.html
也会跑到index.php文件里去,显然 sitemaps/sitemap1.html 是不存在的

 ^(.*)$ 把一切不存在的东西都包括进去了,所以 404 设置不会起作用(index.php 总是存在的)
你需要在那个 .* 上做文章
------解决思路----------------------
RewriteRule ^(.*)/sitemaps/sitemap(\d+)\.html$ $1/sitemaps/sitemap.php?domain=$2

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template