English 中文(简体)
mod_rewrite redirect from any page to home page
原标题:mod_rewrite redirect from any page to home page

I need to redirect if someone goes to any folder e.g. http://site.com/images/ or http://site.com/images to http://site.com. Unless he goes to file e.g. http://site.com/images/index.php in this case it does not redirect

如今

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} (.*)$ [NC]
RewriteRule ^(.*)$ http://%1/ [R=301,L]

但如果有人在上,则认为它并不完美。 它不可行。

牢记服务器配置,需要把htaccess放到每一倍。

最佳回答

我认为,你所期待的是-f

RewriteCond %{REQUEST_FILENAME} !-f

。 http://http://d.apache.org/docs/ 当前/mod/mod_rewrite.html

www.un.org/Depts/DGACM/index_spanish.htm 如果你只想阻止某人拿到档案清单。 您的双管齐下,也许希望考虑增加:

Options -Indexes

如果某一名录没有索引页,这将表明没有显示目录清单的海滩。

。 http://d.apache.org/docs/2.2/mod/core.html#options

最后一个值得注意的事项是,如果你不熟悉“htaccess work”,那么,“pachescans the current rafter and any of its parent rafters - you should be okay with only supplemented a one .htaccess file in their web fundamental for here

问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签