如何用 .htaccess 重写 URL
How to rewrite URL with .htaccess
我需要用 .htaccess
将生成的文件下载 url 修改为另一个
我需要做这个URL:
http://example.com/download.php?file=Cool_Artist_-_Another_Cool_Song_id-1a2b3c4d5e6f7g8h_[www.mysite.com].mp3
改写成这个URL:
http://example.com/download/id-1a2b3c4d5e6f7g8h/Cool_Artist_-_Another_Cool_Song_[www.mysite.com]
谁能帮我解决一下?
您可以在 DOCUMENT_ROOT/.htaccess
文件中使用此代码:
RewriteEngine On
RewriteBase /
RewriteRule ^download/([^/]+)/(.+?)_([^_]+)/?$ ?file=__ [L,QSA,NC]
我需要用 .htaccess
将生成的文件下载 url 修改为另一个我需要做这个URL:
http://example.com/download.php?file=Cool_Artist_-_Another_Cool_Song_id-1a2b3c4d5e6f7g8h_[www.mysite.com].mp3
改写成这个URL:
http://example.com/download/id-1a2b3c4d5e6f7g8h/Cool_Artist_-_Another_Cool_Song_[www.mysite.com]
谁能帮我解决一下?
您可以在 DOCUMENT_ROOT/.htaccess
文件中使用此代码:
RewriteEngine On
RewriteBase /
RewriteRule ^download/([^/]+)/(.+?)_([^_]+)/?$ ?file=__ [L,QSA,NC]