I’m using wordpress
I would like to forward one url to another preferably via wordpress like add_rewrite_rule() but as I know it is not possible. (Because it will be much easier.)
I have few cases that I want to match with same rule
I would like to forward
http://dom.com/sale/product to http://dom.com/product
http://dom.com/sale/hierachicalproduct/product to http://dom.com/hierachicalproduct/product
http://localhost/dom.com/sale/product to http://localhost/dom.com/product
http://localhost/dom.com/sale/hierachicalproduct/product to http://localhost/dom.com/hierachicalproduct/product
I want to remove “/sale” rest will be same.
I do not want to type single rule for every case.
This is the code that I used but problem is this code forwarding like
http://localhost/dom.com/sale/product to http://localhost/product
it is skipping /dom.com side
RewriteRule ^sale/(.+)$ /$1 [R=301,L]
This code should work from .htaccess in
http://localhost/dom.com/
on localhost andhttp://dom.com/
on production host.Make sure these rules are first rules below
RewriteEngine
line.You could try using two capturing groups:
You need to put your code after
RewriteEngine On
So your code should be
I can see n your .htaccess file below code
Just put below code after
RewriteBase /domain.com/
this line