The website address changed. for help, the RewriteRule regular expression was changed because the previous website address was not properly configured. However, I did not expect that Baidu submitted and deleted the website for a long time. now it is still the previous website address, in order not to affect customer access, we want to batch redirect old URLs to new URLs,
The old format is as follows: http://www.songhuala.com/p1099/beijing gift /china_flowers_info.html
New format: http://www.songhuala.com/-p-1099.html
I made the following redirection in. htaccess,
RewriteEngine on
RewriteCond % {REQUEST_URI} ^ p/d + \/. * \/China_flowers_info \. html $
RewriteRule ^ (. *) $ ^-p-/d + \. html $1 [R = 301, L]
However, the correct new URL cannot be targeted. I hope my friends can help me to test this regular expression for one afternoon. Thank you for your patience. Grateful.
Reply to discussion (solution)
RewriteCond % {REQUEST_URI} ^ p/d + \/. * \/China_flowers_info \. html $
RewriteRule ^ (. *) $ ^-p-/d + \. html $1 [R = 301, L]
The marked red part seems to be incorrect.
RewriteEngine On
RewriteBase/
RewriteCond % {REQUEST_URI} p (\ d +)
RewriteRule p (\ d +) http://www.songhuala.com/-p-00001.html [R = permanent, L]
I was in a hurry yesterday and never replied. thank you very much for your reply today.
Later, I asked my friend about idreamsoft.com to solve the problem,
The following describes how to complete redirection.
RewriteEngine on
RewriteRule ^ (.*)? P (\ d + ).*? \. Html $-p-$2 \. html [R = 301, L]
RewriteCond % {REQUEST_URI} ^ p/d + \/. * \/China_flowers_info \. html $
RewriteRule ^ (. *) $ ^-p-/d + \. html $1 [R = 301, L]
The marked red part seems to be incorrect.
Yes. I did not pay attention to it when I was just learning it. I also found a mistake when asked later.
RewriteEngine On
RewriteBase/
RewriteCond % {REQUEST_URI} p (\ d +)
RewriteRule p (\ d +) http://www.songhuala.com/-p-00001.html [R = permanent, L]
Well, I think it's okay, because I did not test it. However, it also helps me understand such a statement.