SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    .htaccess, localhost working, host not working

    Hello everybody.

    I have a website on localhost and a configured .htaccess for the local version but its not working online.

    for example, this is a bit of code that transfers to message.php on localhost

    RewriteRule ^messages/? message.php

    on the host, i tried this...

    RewriteRule ^www.mywebsite.com/messages/? message.php
    Rewriterule ^http://www.mywebsite.com/messages/? message.php (with changing the in php to www.mywebsite.com/message)

    How do I create valid links to my php files and how does apache gets his url?
    For example, if my url is just 'poruke', does apache knows that www.mywebsite.com goes before it?
    What kind of string gets into .htaccess file before being redirected with regular expressions?

    I know that theres an extensive documentation, but its not on my learning schedual yet. Apache is behind design patterns and javascript
    so all the help is welcome in temporary fixes.

    Thank you in advance.

  2. #2
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,276
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by good_boy View Post
    I have a website on localhost and a configured .htaccess for the local version but its not working online.

    RewriteRule ^messages/? message.php
    That rewrite rule looks mostly fine to me. Might be safer to add an end anchor (^messages/?$) but I don't think that's causing your current issue. If this rule works on your local server but breaks on your live server, then I can only suspect that there's either a different configuration or more stuff in your live htaccess file.

    Quote Originally Posted by good_boy View Post
    on the host, i tried this...

    RewriteRule ^www.mywebsite.com/messages/? message.php
    Rewriterule ^http://www.mywebsite.com/messages/? message.php (with changing the in php to www.mywebsite.com/message)
    Definitely none of those will work. The scheme and host will never be part of the string that you're matching against.

    Quote Originally Posted by good_boy View Post
    How do I create valid links to my php files and how does apache gets his url?
    For example, if my url is just 'poruke', does apache knows that www.mywebsite.com goes before it?
    What kind of string gets into .htaccess file before being redirected with regular expressions?
    Htaccess rewrite rules will match on the relative filesystem path. So if the request is for site.com/poruke, then the relative path that will be matched and replaced will be just "poruke".
    "First make it work. Then make it better."

  3. #3
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the answer but the file is copy/pasted from localhost directly to host. I didn't change anything.
    My host provided the .htaccess file form me, an empty one so I presume that it should work.
    My rule for the messages is the first rule in the file and followed by the [L] flag so it shouldn't be that.
    I also have a top rule 'Options +FollowSymLinks'. I doesn't work with it or without it so i changed a rule
    to Options All but that doesn't work either.

    I use xampp. Do you know how can change configuration on the host to reflect that of xampp? I know it might be
    a complicated question so i won't mind if you wont bother with it.

  4. #4
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,276
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by good_boy View Post
    My rule for the messages is the first rule in the file ... I also have a top rule 'Options +FollowSymLinks'.
    Any chance you can show your whole htaccess file? You never know where the real problem may be.
    "First make it work. Then make it better."

  5. #5
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    RewriteEngine On

    RewriteRule ^poruka/? poruka.php [L]
    RewriteRule ^kontakt/? kontakt.php [L]
    RewriteRule ^prijava/? prijava.php [L]
    RewriteRule ^registracija/? registracija.php [L]
    RewriteRule ^rezervacije/([0-9]+)/? rezervacija.php?id=$1 [L]
    RewriteRule ^rezervacije/(delete-[0-9]+)/? rezervacija.php?do=$1 [L]
    RewriteRule ^(svakodnevno-cvijece|blagdani-i-praznici|gotovi-aranzmani|posebne-prigode|uredivanje-doma)/? odjeljci.php?odjeljak=$1 [L]
    RewriteRule ^Oliva-(.*)/([0-9]+)/?$ proizvod.php?naslov=$1&id=$2 [L]

    this is croatian. cause im croat haha. anyway, this is it, nothing changed.
    The first rule is to poruka.php a.k.a message.php.

  6. #6
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i should also mention that i use a free domain for the site. its 000webhost.com if thats a clue.

  7. #7
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i did it. i solved it. i only had to add RewriteBase / to the start of the file. Thanks a lot for your help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •