htaccess重定向到wamp本地地址

I have an already online hosted website which I have downloaded and configured for wamp. The only problem which occurred is that if I click on any link on my local website I will get redirected to my online website.

Unfornutally I cannot set up my htaccess so that it's changing the online links to the local server.

So for instance:

Having a link on a site which redirects to www.example.com/blog should be rewritten to redirect to example.dev/blog.

For that I have tried something like that:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com(.*) [NC]
RewriteRule ^(.*)$ example.dev/$1 [R=301,L]

But it does not work.

EDIT: A more in depth example:

I have a website which address is: www.example.com its local wamp address is example.dev. Now I have a link <a href="http://www.example.com/shop.html">Shop</a> within a index.html of the local example.dev root. And now I need a way to redirect http://www.example.com/shop.html to http://example.dev/shop.html. This should be apply to all sub pages not only for shop. Also for style sheets etc.

Two things must be changed in the rules

  • HTTP_HOST contains only the host, nothing else. So the condition should rather be

    RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
    
  • The target will be interpreted as a file system path. To redirect it to another host, you must specify a complete URL including the protocol (http)

    RewriteRule ^(.*)$ http://example.dev/$1 [R,L]
    

Another approach to redirect one site to another wholesale, can be done by Redirect

Redirect /blog http://example.dev/blog

or doing this with all requests

Redirect / http://example.dev/

Looking at your update, it seems you don't need .htaccess at all. You must rather change the relevant links to either

<a href="http://www.example.dev/shop.html">Shop</a>

or better yet, don't use absolute URLs

<a href="/shop.html">Shop</a>

Similar for style sheets or Javascript files.