这是我的.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文件(如上所示)?谢谢。