My htaccess doesn't work on localhost

Discussion in 'Apache' started by mblascog, Mar 12, 2013.

  1. #1
    Hi everybody,
    I need to modify a web that is working in the server.
    I'd like to download it to my computer and test it. For this reason I have to change the htaccess file to change the redirects, but it doesn't work, appears 404 error
    Thanks for your helpfull.

    This is the code.
    RewriteEngine On
     
    #rewritecond %{http_host} ^camps.es [nc] 
    rewritecond %{http_host} ^camps [nc]
     
    #rewriterule ^(.*)$ http://www.camps.es/$1 [r=301,nc] 
    rewriterule ^(.*)$ http://localhost:8887/camps/$1 [r=301,nc] 
    Code (markup):

     
    mblascog, Mar 12, 2013 IP
  2. pr0t0n

    pr0t0n Well-Known Member

    Messages:
    243
    Likes Received:
    10
    Best Answers:
    10
    Trophy Points:
    128
    #2
    As far as I can see the purpose of those rules is to rewrite non-www to www domain name. When using it in localhost that's pointless, and it will not work anyway (because www . localhost will not work). So you can just comment out those rules when working in localhost and make sure to upload it to the server when finished.
    As a side note, when it was used on the server camps.es was the part of host, but when you are using it in localhost camps is no longer a host, but merely a folder, so http_host will not match camps in this case anyway.
     
    pr0t0n, Mar 12, 2013 IP
  3. mblascog

    mblascog Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    Thanks for your answer and I apologise for my poor english. I'm not sure to understand what you have suggested to do.
    I've commented theses rules but I've still have the same problem.
    When the web is executed in the server, theses rules are to open this page, /city/index.php with some parameters.
    If I comment this rules there is no way to indicate where index.php is.

    I copy the nexts rules of the .htaccess file, perhaps will be easier for you to understand what I mean.

        RewriteRule ^(pisos-casas|locales-oficinas|solares-parcelas|naves-industriales|parkings|inmuebles-singulares)/(.[a-zA-Z0-9_\-]{1,50})-(.*)_(.*)\.html$ /sabadell/index.php?cat=$1&lng=es&op=$2&od=$3&pg=$4 [L] #OPERACIONES
        RewriteRule ^(pisos-cases|locals-oficines|solars-parceles|naus-industrials|parquings|immobles-singulars)/(.[a-zA-Z0-9_\-]{1,50})-(.*)_(.*)\.html$ /sabadell/index.php?cat=$1&lng=ca&op=$2&od=$3&pg=$4 [L] #OPERACIONES
    
    Code (markup):
     
    mblascog, Mar 12, 2013 IP
  4. jokerff

    jokerff Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #4
    check your http.conf file. be sure that there u enabled ur apache rewrite module: LoadModule rewrite_module modules/mod_rewrite.so smth like that...

    and another line AccessFileName .htaccess
    othervise ur rules doesnt work.
     
    jokerff, Mar 22, 2013 IP