2012-03-28 10 views
0

これは私の.htaccessファイルは、次のようになります。ディレクトリ内のすべてのファイルのエイリアスを作成する方法は?

# Original 
# If you modify this file then change the above line to: # Modified 
<IfModule mod_rewrite.c> 
    RewriteEngine On 
    # Certain hosts may require the following line. 
    # If vanilla is in a subfolder then you need to specify it after the /. 
    # (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum) 
    # RewriteBase/
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L] 
</IfModule> 

私は.htaccessファイルで書き換えルールで、私は長いURLを短縮するために使用することができURLエイリアスを作成することができますお読みください。このディレクトリのすべてのファイル(http://example.com/cache/Sitemaps/)がhttp://example.com/*に短縮(リダイレクトされないように)されるように、ワイルドカード書き換えルールを作成します。例えば

、もしfile1.xml、file2.xml、file3.xml ...というように http://example.com/cache/Sitemaps/に存在するファイルがある、私が欲しい:

http://example.com/cache/Sitemaps/file1.xmlhttp://example.com/file1.xml
http://example.com/cache/Sitemaps/file2.xmlhttp://example.com/file2.xml
http://example.com/cache/Sitemaps/file3.xmlhttp://example.com/file3.xml
...などです! (→は「エイリアス」または「短縮」を表します)

どうすればよいですか? .htaccessファイル(上記参照)にどこを追加すればよいですか?ありがとう。ここで

答えて

1

DOCUMENT_ROOT自体に置き、あなたの変更の.htaccessです:

# Modified 
# If you modify this file then change the above line to: # Modified 
<IfModule mod_rewrite.c> 
    RewriteEngine On 
    # Certain hosts may require the following line. 
    # If vanilla is in a subfolder then you need to specify it after the /. 
    # (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum) 
    RewriteBase/

    # shorten /cache/Sitemaps/foo.xml to /foo.xml 
    RewriteRule ^((?!cache/Sitemaps/).*\.xml)$ cache/Sitemaps/$1 [NC,L] 

    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ index.php?p=$1 [QSA,L] 

</IfModule> 
関連する問題