在httpd.conf文件中,應該已經禁止訪問.HT *文件可能會是這樣的一行:如果你想成爲redundent
<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</Files>
,使用文件或FilesMatch保護它可能會很好。如果你想爲此使用重寫,你可以拋出一個404,就好像它不存在一樣。
這裏是一個目錄/ INC重定向(不是mod_rewrite的)到404頁
這是在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]
最後會從服務器whi調用「/」如果根據目錄索引存在,ch將首先是「index.php」。
答案是否適合您或您是否需要更多幫助?如果你點擊回答(如果你不需要更多的幫助),那麼人們會知道不需要更多的輸入。 – craniumonempty