I'm trying to write a rewrite rule to redirect files in my new webhelp system (it's a stand alone website). I have two things I try to take into account - I want to redirect only files that are in the http://www.mydomain.com/webhelp folder. I need to change the .html in the end to .htm... I manage to find each rule by itself by matching the http://www.mydomain.com/webhelp , but when I try the rewrite cond it breaks...
Basically, its http://www.mydomain.com/webhelp/hello.html into http://www.mydomain.com/webhelp/hello.htm without changing http://www.mydomain.com/index.html
Would really appreciate any help. Thanks!
You need to use backreferences. Something like:
RewriteRule ^www/webhelp/(.*)[.]html([#])(.*)[.]html$ www/webhelp/$1.htm$2$3.htm
RewriteRule ^www/webhelp/(.*)[.]html$ www/webhelp/$1.htm
If you put the following in a .htaccess
file in your webhelp
folder, it should achieve what you're looking for:
RewriteEngine on
RewriteBase /webhelp/
RewriteRule ^(.*).html$ $1.htm [R=301,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.