我正在将网站更改为wordpress,这将导致许多网址发生变化。
示例网址: download.html的http://www.example.com/download/NUMBER/name
应该301重定向到:
https://www.example.com/download/naam-van-de-download/
目前的htaccess声明:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~downloadsite/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~downloadsite/index.php [L]
</IfModule>
我认为要添加的代码应为:
Options FollowSymlinks MultiViews
RewriteEngine on
RewriteBase /~downloadsite/
# keep replacing space to hyphen until there is no space use internal rewrite
RewriteRule ^([^\s%20]*)(?:\s|%20)+(.*)$ $1-$2 [N,E=NOSPACE:1,DPI]
# when there is no space make an external redirection
RewriteCond %{ENV:NOSPACE} =1
RewriteRule ^download/(.*)/(.*).html$ download/$2/ [L, R=301]
但它一直给我500状态错误。 即使我只在当前代码的任何一行添加此语句,它也会产生错误:
RewriteRule ^download/(.*)/(.*).html$ download/$2/ [L, R=301]
任何人都可以指出出了什么问题?