我正在运行一个WordPress多站点,如果在请求的位置找不到该文件,我想从一个diff位置加载文件
例如:
请求的URL:http://example.com/wp-content/sites/2/uploads/2018/01/filename.jpg
如果文件存在,则可以从该url加载,否则应该重新输入路径
重写网址http://example.com/wp-content/uploads/2018/01/filename.jpg
应该对具有 sites / {anynumber} / uploads /
的网址执行一次我尝试使用下面的htaccess代码
RewriteCond %{REQUEST_URI} ^/uploads/sites/\d{4}/\d{2}/.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(uploads/sites)(/\d{4}/\d{2}/.+)$ $1/uploads$2
但是我得到500错误
这是我的完整htaccess
RewriteEngine On
RewriteBase /wp400/
RewriteRule ^index\.php$ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
RewriteCond %{REQUEST_URI} ^/uploads/sites/\d{4}/\d{2}/.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(uploads/sites)(/\d{4}/\d{2}/.+)$ $1/uploads$2