0

我正在 .htaccess 中尝试这个

RewriteEngine On # Turn on the rewriting engine 
RewriteRule /mymedia/sample.mp3 http://somedomain.com/file/sample.mp3 [NC,L]

但它不工作

4

1 回答 1

1

RewriteRulein.htaccess与前导斜杠不匹配/

试试这个代码:

RewriteEngine On
RewriteRule ^mymedia/sample\.mp3$ http://somedomain.com/file/sample.mp3 [R,NC,L]

或者,如果文件名与您的示例中所示相同:

RewriteRule ^mymedia/(sample\.mp3)$ http://somedomain.com/file/$1 [R,NC,L]

编辑要在目标文件名中允许空格:

RewriteRule ^mymedia/file\.mp3$ http://somedomain.com/file/my\ file.mp3 [R,NC,L]
于 2013-09-14T12:01:59.003 回答