I'm trying to rewrite the following into htaccess using - redirect 301
redirect "mysite.com/longname/{20 character string}" to "mysite.com/shortname/{10 character string}"
basically to redirect the "longname" to "shortname" and cut the "20 character string" to the first 10 characters
so when I go to mywebsite.com/longname/aaaaabbbbbcccccddddd, it rewrites it into mywebsite.com/shortname/aaaaabbbbb
Here's what I have so far:
RewriteEngine On
RewriteRule /longname/(.*) /shortname/$1 [R=301,L]
You should be able to limit the input using a regular expression such as:
RewriteEngine On
RewriteRule /longname/(.{0,10}) /shortname/$1 [R=301,L]
This will match a string of 0-10 characters following /longname/.
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.