I would like to move all content from /downloads/assets/
folder to /downloads/
folder.
How do I add redirect for /downloads/assets/{anystring}
to /downloads/{anystring}
?
Now I manually add every redirect like this:
RewriteRule ^downloads/assets/views?$ /downloads/views [L]
But it's a dream job. Can we use variables instead?
Spend some time with the RewriteRule
documentation , as this is a very rudimentary usage. You will need to capture everything after assets/
in (.*)
and rewrite it as $1
.
RewriteEngine On
RewriteRule ^downloads/assets/(.*) downloads/$1 [L]
The above will perform a silent internal rewrite. If you need to redirect the browser rather than silently rewrite, use [L,R=301]
instead of [L]
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.