HTAccess - 删除长路径列表中的冗余

时间:2014-04-26 03:49:50

标签: apache .htaccess

如何消除HT Access file的冗余?我可以定义一个常量来代替重复" http://team854.com/"

#Make pages render without their extension in the url
Options +MultiViews

ErrorDocument 403 /php/error.php
ErrorDocument 404 /php/404.php
ErrorDocument 405 /php/error.php
ErrorDocument 408 /php/error.php
ErrorDocument 500 /php/error.php
ErrorDocument 502 /php/error.php
ErrorDocument 504 /php/error.php

# Do not change this line.
RewriteEngine on


# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?team854.com$


# Change 'subfolder' to be the folder you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/php/

# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Change 'subfolder' to be the folder you will use for your main domain.
RewriteRule ^(.*)$ /php/$1

# Change yourdomain.com to be your main domain again.
# Change 'subfolder' to be the folder you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.

RewriteCond %{HTTP_HOST} ^(www.)?team854.com$
RewriteRule ^(/)?$ php/index.php [L]


SetEnv INDEX_URL http://team854.com/

############################################################################################################
#Apaxy by @adamwhitcroft
#For a full breakdown of the mod_autoindex module:
#http://apache.org/docs/2.2/mod/mod_autoindex.html
    # ENABLE INDEXING
    Options +Indexes

    # INDEX OPTIONS
    IndexOptions +Charset=UTF-8 +FancyIndexing +IgnoreCase +FoldersFirst +XHTML +HTMLTable +SuppressRules +SuppressDescription +NameWidth=*

    # HIDE /theme DIRECTORY
    #IndexIgnore .htaccess /theme

#
#GENERAL ICONS (BLANK, DIRECTORY, PARENT DIRECTORY)
#

#
#Replace {FOLDERNAME} with your directory URL eg:
#If your directory is http://mywebsite.com/share/
#you would change to:
#
#AddIcon /share/theme/icons/blank.png ^^BLANKICON^^
#

    AddIcon http://team854.com/css/Apaxy/icons/blank.png ^^BLANKICON^^
    AddIcon http://team854.com/css/Apaxy/icons/folder.png ^^DIRECTORY^^
    AddIcon http://team854.com/css/Apaxy/icons/folder-home.png ..
    #EXTENSION SPECIFIC ICONS
    AddIcon http://team854.com/css/Apaxy/icons/audio.png .aif .iff .m3u .m4a .mid .mp3 .mpa .ra .wav .wma .f4a .f4b .oga .ogg
    AddIcon http://team854.com/css/Apaxy/icons/bin.png .bin
    AddIcon http://team854.com/css/Apaxy/icons/c.png .c
    AddIcon http://team854.com/css/Apaxy/icons/calc.png .xlsx .xlsm .xltx .xltm .xlam .xlr .xls .csv
    AddIcon http://team854.com/css/Apaxy/icons/css.png .css
    AddIcon http://team854.com/css/Apaxy/icons/deb.png .deb
    AddIcon http://team854.com/css/Apaxy/icons/doc.png .doc .docx .docm .dot .dotx .dotm .log .msg .odt .pages .rtf .tex .wpd .wps
    AddIcon http://team854.com/css/Apaxy/icons/draw.png .svg
    AddIcon http://team854.com/css/Apaxy/icons/eps.png .ai .eps
    AddIcon http://team854.com/css/Apaxy/icons/gif.png .gif
    AddIcon http://team854.com/css/Apaxy/icons/html.png .html .xhtml .shtml .htm
    AddIcon http://team854.com/css/Apaxy/icons/ico.png .ico
    AddIcon http://team854.com/css/Apaxy/icons/java.png .jar
    AddIcon http://team854.com/css/Apaxy/icons/jpg.png .jpg .jpeg
    AddIcon http://team854.com/css/Apaxy/icons/js.png .js .json
    AddIcon http://team854.com/css/Apaxy/icons/markdown.png .md
    AddIcon http://team854.com/css/Apaxy/icons/package.png .pkg .dmg
    AddIcon http://team854.com/css/Apaxy/icons/pdf.png .pdf
    AddIcon http://team854.com/css/Apaxy/icons/php.png .php .phtml
    AddIcon http://team854.com/css/Apaxy/icons/png.png .png
    AddIcon http://team854.com/css/Apaxy/icons/ps.png .ps
    AddIcon http://team854.com/css/Apaxy/icons/psd.png .psd
    AddIcon http://team854.com/css/Apaxy/icons/rar.png .rar
    AddIcon http://team854.com/css/Apaxy/icons/rb.png .rb
    AddIcon http://team854.com/css/Apaxy/icons/rpm.png .rpm
    AddIcon http://team854.com/css/Apaxy/icons/rss.png .rss
    AddIcon http://team854.com/css/Apaxy/icons/sql.png .sql
    AddIcon http://team854.com/css/Apaxy/icons/tiff.png .tiff
    AddIcon http://team854.com/css/Apaxy/icons/text.png .txt .nfo
    AddIcon http://team854.com/css/Apaxy/icons/video.png .asf .asx .avi .flv .mkv .mov .mp4 .mpg .rm .srt .swf .vob .wmv .m4v .f4v .f4p .ogv
    AddIcon http://team854.com/css/Apaxy/icons/xml.png .xml
    AddIcon http://team854.com/css/Apaxy/icons/zip.png .zip
    DefaultIcon http://team854.com/css/Apaxy/icons/default.png
    #THEME FILES
    HeaderName http://team854.com/css/Apaxy/header.html
    ReadmeName http://team854.com/css/Apaxy/footer.html
    IndexStyleSheet http://team854.com/css/Apaxy/style.css

1 个答案:

答案 0 :(得分:1)

您在AddIcon指令中确实不需要主机名。只需使用它:

AddIcon /css/Apaxy/icons/blank.png ^^BLANKICON^^
AddIcon /css/Apaxy/icons/folder.png ^^DIRECTORY^^
...
...