首页 / ACCESS / .htaccess伪静态问题
.htaccess伪静态问题
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了.htaccess伪静态问题,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3949字,纯文字阅读大概需要6分钟。
内容图文
![.htaccess伪静态问题](/upload/InfoBanner/zyjiaocheng/203/943f5982701b4b67bd860bf623111110.jpg)
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 总是存在的)
你需要在那个 .* 上做文章
sitemaps/sitemap1.html
这些也准备伪静态
这个情况下我要怎么办
请教个伪静态的问题
我在弄那个whois查询的时候伪静态
http://whois.xxx.com/womai.cn这个的
RewriteEngine on
Rewritebase /
ErrorDocument 404 /404.html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?domain=$1 [QSA,PT,L]
用了这个是可以的
但是我现在想在上面弄多一个文件伪静态
whois.xxx.com/sitemaps/sitemap1.html
whois.xxx.com/sitemaps/sitemap2.html
whois.xxx.com/sitemaps/sitemap3.html
这样的
不知道怎么弄,不知道怎么在里面添加内容
我自己添加的出问题了。
whois.xxx.com/sitemaps/sitemap1.html
这样的会转变成 index.php?domain=sitemaps/sitemap1.html
你在 index.php 中判断处理一下就可以了
这个不好判断的,还是要走到htaccess
因为这个东西又不是只有二样。
建议你好好看看框架的路由指派
比较man呀
弄完这个还要去弄其他网站
RewriteEngine on
ErrorDocument 404 /404.html
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?domain=$1 [QSA,PT,L]
RewriteRule ^(.*)/\w+/[A-za-z]+(\d+)\.html$ sitemaps/sitemap.php?domain=$2
这样不行
RewriteRule ^(.*)/sitemaps/sitemap(\d+)\.html$ $1/sitemaps/sitemap.php?domain=$2
不行,他还是会跑到index.php里去。这个问题估计在第一个伪静态那里出问题了
你那样当然不行!
次序问题
RewriteRule ^(.*)/\w+/[A-za-z]+(\d+)\.html$ sitemaps/sitemap.php?domain=$2 [L]
RewriteRule ^(.*)$ index.php?domain=$1 [QSA,PT,L]
RewriteEngine on
ErrorDocument 404 /404.html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/sitemaps/sitemap(\d+)\.html$ $1/sitemaps/sitemap.php?domain=$2
RewriteRule ^(.*)$ index.php?domain=$1 [QSA,PT,L]
这样的不行,估计是上一次影响了下一条
我有 [L] 你却没有
RewriteEngine on
ErrorDocument 404 /404.html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/\w+/[A-za-z]+(\d+)\.html$ sitemaps/sitemap.php?domain=$2 [L]
RewriteRule ^(.*)$ index.php?domain=$1 [QSA,PT,L]
这样也不行,真的
再向上调
RewriteRule ^(.*)/\w+/[A-za-z]+(\d+)\.html$ sitemaps/sitemap.php?domain=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?domain=$1 [QSA,PT,L]
RewriteEngine on
ErrorDocument 404 /404.html
RewriteRule ^(.*)/\w+/[A-za-z]+(\d+)\.html$ sitemaps/sitemap.php?page=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?domain=$1 [QSA,PT,L]
不行,有什么办法修改index.php 那一行,我那一行的作用是
whois.hangye5.com/womai.cn 后面是域名
我行,你不行。不好说什么了
可能是你的思路就错了,因为给 RewriteRule 的串中不会含有域名
这个大家都这样弄的
whois.22.cn/womaicn
RewriteEngine on
ErrorDocument 404 /404.html
RewriteRule ^sitemaps/sitemap([0-9]+).html$ /sitemaps/sitemap.php?domain=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?domain=$1 [QSA,PT,L]
这样可以了
内容总结
以上是互联网集市为您收集整理的.htaccess伪静态问题全部内容,希望文章能够帮你解决.htaccess伪静态问题所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。