问题描述
我想实现的 301重定向的距离 http://www.onbip.com/index-en.html
到 http://www.onbip.com/
在htaccess文件,我有:
In htaccess file I have:
- 重写规则
^ htaccess的$ - [F,L]#403禁止
- 重写规则
^ INC / - [F,L]
- 的RewriteCond
%{HTTP_HOST} ^ onbip \ .COM
- 重写规则
^ $ HTTP(*)://www.onbip.com/$1 [R =永久,L]
- 重写规则
^指数 - ?([^ \] +)\ HTML $的index.php LANG = $ 1 [L]
- RewriteRule
^.htaccess$ - [F,L] #403 Forbidden
- RewriteRule
^inc/ - [F,L]
- RewriteCond
%{HTTP_HOST} ^onbip\.com
- RewriteRule
^(.*)$ http: //www.onbip.com/$1 [R=permanent,L]
- RewriteRule
^index-([^\.]+)\.html$ index.php?lang=$1 [L]
我需要规范的默认页,这将是 http://www.onbip.com/
I Need to standardize the default page which will be http://www.onbip.com/
如何?
推荐答案
在httpd.conf文件,应该已经有一条线,禁止访问.HT *文件可能会是这样的:
In your httpd.conf file, there should already be a line to forbid access to .ht* files that will probably look like this:
<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</Files>
如果你想成为redundent,使用文件或FilesMatch来保护它很可能是不错的。如果你想使用重写这一点,你可以扔了404,就好像它不存在。
If you want to be redundent, using Files or FilesMatch to protect it would probably be good. If you want to use Rewrite for this, you could throw a 404 as though it doesn't exist.
下面是一个重定向(而不是mod_rewrite的)一个目录/ INC至404页
Here is a redirect (not a mod_rewrite) for a directory /inc to a 404 page
这是在 http://httpd.apache.org/docs/2.0 /mod/mod_alias.html
Redirect 404 /inc
现在用于重写
看 http://httpd.apache.org/docs/current/mod /mod_rewrite.html
#Set the page (and order of if they are there) to be shown if asked for a directory
#just put index.php if that's all you want
DirectoryIndex index.php index.html
RewriteEngine on
# if not www.onbip.com, then send to http://www.onbip.com
RewriteCond %{HTTP_HOST} !^www\.onbip\.com [NC]
RewriteRule ^(.*)$ http://www.onbip.com/$1 [R=301,NC,L]
# Now if entered "/index-ab.html" then call "/?lang=ab"
# You might want to see about the regex for proper lang, I put something like "en" or "us-en"
RewriteBase /
RewriteRule ^index-([a-z]{2}(-[a-z]{2})?)\.html$ ?lang=$1 [R=301,NC,L]
最后将从这将是的index.php第一,如果按照目录索引所在的服务器称为/。
The last will call "/" from the server which will be "index.php" first if it exists according to directory index.
这篇关于MOD-重写在.htaccess?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!