這是我的.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。我想創建一個通配符重寫規則,以便此目錄中的所有文件: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.xml→http://example.com/file1.xml
http://example.com/cache/Sitemaps/file2.xml→http://example.com/file2.xml
http://example.com/cache/Sitemaps/file3.xml→ http://example.com/file3.xml
...等等! (其中→表示'別名或縮寫爲')
我該如何做?我應該在哪裏添加它在我的.htaccess文件(如上所示)?謝謝。