重定向只有HTML文件? [英] Redirect only HTML files?

查看:223
本文介绍了重定向只有HTML文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要为.htaccess重定向所有的HTML文件的主页。我看着这家伙的问题( htaccess的重定向所有的HTML文件),并写了这个code:

I want to .htaccess redirect all HTML files to the home page. I looked at this guy's question (htaccess redirect all html files), and wrote this code:

RewriteCond %{HTTP_HOST} ^pandamonia.us$ [OR]  
RewriteCond %{HTTP_HOST} ^www.pandamonia.us$  
RewriteRule .*\.html$ "http\:\/\/pandamonia\.us\/" [L]

,但问题是,它也主页重定向到本身,导致宇宙结束

but the problem is that it also redirects the homepage to itself, causing the universe to end.

所以我的问题是我怎么能每个HTML页面是的没有的网页重定向到主页。

So my question, is how can I redirect every HTML page that is not the homepage to the homepage.

<一个href="http://stackoverflow.com/questions/1732275/exclude-certain-subfolders-and-domains-in-redirects">Exclude某些子文件夹和域重定向

推荐答案

试着改变。* + 在正则表达式,这应该是指至少一个字符,而不是零个或多个字符,因此应尽量避免空字符串。

Try changing .* to .+ in the regexp, that should mean 'at least one character' instead of zero or more characters, so the empty string should be avoided.

等待。初始'/'是包括在内。尝试一下这样的:

Wait. The initial '/' is included. Try it like:

RewriteRule /.+\.html$ "http\:\/\/pandamonia\.us\/" [L]

这篇关于重定向只有HTML文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆