Wordpress Rewrite only external

Discussion in 'Apache' started by SharingEngines, Oct 22, 2012.

  1. #1
    Hi,

    I have a website indexed on google http://www.1234.com/annunci/

    But I need to change it to http://www.1234.com/annuncio/

    I use this rewrite code on htaccess

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^annunci/(.*) http://www.1234.it/annuncio/$1 [R=301,L]
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    Code (markup):
    He works well.

    When I click in a google URL he rewrite http://www.1234.com/annunci/ into http://www.1234.com/annuncio/

    The problem is I use this internal link http://www.1234.com/annunci/ and when I click on it he transforms to http://www.1234.com/annuncio/

    I need the htaccess only rewrite the external links and not internal.

    Could you help me please?
    Thank you in advance
     
    SharingEngines, Oct 22, 2012 IP
  2. pr0t0n

    pr0t0n Well-Known Member

    Messages:
    243
    Likes Received:
    10
    Best Answers:
    10
    Trophy Points:
    128
    #2
    Not quite sure if that's a good idea, but you could add some condition there, for example
    
    RewriteCond %{HTTP_REFERER} !^http://www\.1234\.it [NC]
    
    Code (markup):
    prior to your RewriteRule directive. So it looks like this:
    
    ....
    RewriteCond %{HTTP_REFERER} !^http://www\.1234\.it [NC]
    RewriteRule ^annunci/(.*) http://www.1234.it/annuncio/$1 [R=301,L]
    ...
    
    Code (markup):
    This will create some duplicate content on Search Engines though.. so I hope you know what you are doing :)

    Cheers.
     
    pr0t0n, Oct 22, 2012 IP
  3. coder77

    coder77 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    sorry wrong place.
     
    coder77, Nov 1, 2012 IP