我需要将旧网址重定向到新的网址结构
old is http://website.com/mp3/song-name/
new是http://website.com/song-name-mp3-download.html
我怎样才能使用mod_rewrite?
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^play/(\d+)/.*$ playlist.php?action=shareview&id=$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ search.php?search=$1 [L]
RewriteRule 404.html 404.php
RewriteEngine on
RewriteCond $1 [A-Z]
RewriteRule ^/?(.*)$ /${lowercase:$1} [R=301,L]
<IfModule mod_deflate.c>
<FilesMatch "\.(php|js|css|mp3|wmv|flv|html|htm)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
ErrorDocument 404 /mp3/404.html
</IfModule>
答案 0 :(得分:1)
您可以在DOCUMENT_ROOT/.htaccess
文件中使用此代码:
RewriteEngine On
RewriteBase /
RewriteRule ^mp3/([^/]+)/?$ $1-mp3-download.html [L,NC,NE,R=302]