1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

[HELP]

Discussion in 'Apache' started by karea12, Apr 4, 2017.

  1. #1
    Hello folks!
    SEMrush
    Short question here, I'm having a problem with .htaccess redirect function.

    ====

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
    RewriteRule ^ %1 [R,NC]
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\index.html [NC]
    RewriteRule ^ %1 [R,NC]
    
    
    ## ## Internal Redirect
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^ %{REQUEST_URI}.html
    Code (markup):
    ====

    It works well, cutting the .html and the index.html from the url in the browser, but when a special character like a acute sign à or another ç, ã, it redirects to the 3 code symbol character:

    The folder structure/file is:
    /public_ftp/reidadedetizacaorj/orçamentobão.html

    ACTUAL BEHAVIOR:
    http://reidadedetizacaorj.com/or%C3%A7amentob%C3%A3o

    EXPECTED BEHAVIOR:
    http://reidadedetizacaorj.com/orçamentobão

    Because of this, host gator shows a 404 page because obviously because or%25C3%25A7amentob%25C3%25A3o is not a file in the server.

    Can you guys help me with the needed modifications on the .htaccess file?
     
    Solved! View solution.
    Last edited by a moderator: Apr 4, 2017
    karea12, Apr 4, 2017 IP
    SEMrush
  2. #2
    Try this:

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
    RewriteRule ^ %1 [R,NC,NE]
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\index.html [NC]
    RewriteRule ^ %1 [R,NC,NE]
    
    
    ## ## Internal Redirect
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^ %{REQUEST_URI}.html
    Code (markup):
     
    nsb2006, Apr 13, 2017 IP
    wisdomtool likes this.
  3. karea12

    karea12 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    Thanks @nsb2006 !
    It worked like a charm!

    What the [NE] does differently from the previous code?
     
    karea12, Apr 13, 2017 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,628
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    PoPSiCLe, Apr 13, 2017 IP
  5. nsb2006

    nsb2006 Member

    Messages:
    12
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    43
    #5
    Like @PoPSiCLe said, the tag will stop converting the special character, and the 404 error would be solved.
     
    nsb2006, Apr 13, 2017 IP