I have so dumb with rewrite rules, but I am trying to relocate my old-domain to a new one but inside a directory that is not a problem, with this code:.
That works for homepage and files, but not directories path.
The question is that I need also to redirect 301, all post (yes is a wordpress site) to the new one to keep the same structure and old link rediect to new one same post . By eg:
I assume you are using Apache as a webserver, put the code in a .htaccess file and have RewriteEngine On somewhere in that file?
If so, let’s have a look at your code
RewriteCond %{HTTP_HOST} ^.*$
“If the request is for any domain”… Hmm. That doesn’t do very much, does it, since every request is for a domain, that’s kind of the whole point. You can (and should) remove this line
You shouldn’t use double quotes around the target URL
2a. You shouldn’t escape slashes in the target URL
2b. You shouldn’t escape the colon in the target URL
2c. You shouldn’t escape the dots in the target URL
You shouldn’t use :redhot: .* :redhot: if you don’t have to, since it will usually cause more problems than it solves (well, not in this particular case since you 301 redirect so you can’t get loops, but usually it does).
woow, a lot of issues to make it not to work LOL… thanks a lot for the input, as said: I am so dumb with mod-rewrite.
The code that you suggest work very good for homepage and files, but not for the post; instead I was thinking that like is a Wordpress site (and post are rewrite for permalinks options), I must to include your line suggested after the rewritecond creates for wordpres. That makes it finally works with all files, directories, tags and anything in the site. The final code is: