Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    135
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Script working on one server, error on another

    Hi,

    I wrote a little .htaccess file, working great in 2-3 websites I have.
    Unfortunately, it causes a 500 Internal Server Error in 2 other websites. I think the problem might relate to authorization somehow, although I'm not sure.

    Here's the complete .htaccess file:
    Code:
    RewriteEngine on
    RewriteBase /
    ReWriteRule \.htaccess [F]
    RewriteRule ^([a-zA-Z\-/]+)/([a-zA-Z\-]+)/?$ index.php?parent=$1&url=$2 # <- problematic line, removing it solves the error
    RewriteRule ^([a-zA-Z\-]+)/?$ index.php?url=$1
    What can cause this error? Should I add something to php.ini, or to the .htaccess itself?


    Thanks a lot.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Do you have access to the server meaning can you edit the httpd.conf file? Some servers don't load the rewrite_module which might cause your file to give the 500 error.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Regular Coder
    Join Date
    Aug 2006
    Posts
    135
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, I do. Where can I find this file? I looked at my FTP server, but no luck. Should I create it?

    BTW, as I wrote in the code before - removing the one before last line in the code fixes the error, but of course that's not the solution, because then the file doesn't do its purpose.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Its not something you can really create. Its not going to be on your main site. To enable this you will need to have physical access to the server itself meaning the computer that hosts your site. If you don't have this then I think you are out of luck unless you convince your webhost to enable the mod_rewrite module. I guess the question at hand is are you running your own servers or are you on a shared hosting plan?
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    Regular Coder
    Join Date
    Aug 2006
    Posts
    135
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The problem occurs on my websites hosted in Godaddy's shared hosting.
    The websites where this code works fine are hosted in Godaddy's virtual dedicated server.

    That means my only solution is to contact Godaddy?

  • #6
    Regular Coder
    Join Date
    Aug 2006
    Posts
    135
    Thanks
    0
    Thanked 0 Times in 0 Posts
    _Aerospace_Eng_, thanks a lot for your help so far, but I don't think this is the problem. Maybe something else?

  • #7
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Hmm guess that rules that out. Try this
    Code:
    RewriteEngine on
    RewriteBase /
    ReWriteRule \.htaccess [F]
    RewriteRule ^(.*)/(.*)/?$ index.php?parent=$1&url=$2
    RewriteRule ^(.*)/?$ index.php?url=$1
    I'm guessing you are wanting /somethinghere/somethingelsehere to rewrite to index.php?parent=somethinghere&url=somethingelsehere
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #8
    Regular Coder
    Join Date
    Aug 2006
    Posts
    135
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What almost do the trick. The problem (a big one) is that it doesn't display images located in sub-directories.
    What do you think about this one:
    Code:
    RewriteEngine on
    RewriteBase /
    ReWriteRule \.htaccess [F]
    RewriteRule ^([a-zA-Z\-\/]+)/([a-zA-Z\-]+)/?$ index.php?parent=$1&url=$2
    RewriteRule ^([a-zA-Z\-]+)/?$ index.php?url=$1
    A very small change to the original I posted, but in a (superficial) quick test seems to work.
    UPDATE: that's not working properly either. this existing page: www.mydomain.com/dir-a/dir-b - not working (I'm referred to 404 not found).

    So I guess we're back to square one. Any ideas?
    Last edited by b_hole; 06-12-2007 at 11:07 AM.

  • #9
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Looks fine to me. If it works it works.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #10
    Regular Coder
    Join Date
    Aug 2006
    Posts
    135
    Thanks
    0
    Thanked 0 Times in 0 Posts
    See my update to my previous post. The code isn't working properly.

  • #11
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Post your code for index.php including php.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #12
    Regular Coder
    Join Date
    Aug 2006
    Posts
    135
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't see how index.php plays a role in this issue, but lets say it only print the values of $url and $parent.

    Just to make myself clear: this URL works fine:
    www.mydomain.com/dir-a
    But in deeper URLs I get the not-found error:
    www.mydomain.com/dir-a/dir-b

  • #13
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    This will work if none of the directories have numbers in them.
    Code:
    RewriteBase /
    ReWriteRule \.htaccess [F]
    RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)/?$ /index.php?parent=$1&url=$2
    RewriteRule ^([a-zA-Z]+)/?$ /index.php?url=$1
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #14
    Regular Coder
    Join Date
    Apr 2007
    Posts
    295
    Thanks
    0
    Thanked 19 Times in 19 Posts
    In your last code, it looks like it's the \/ (backslash slash) in the second rule that's causing it to not work as expected

    Aerospace's example should work, I amended his to support hyphens and numbers
    Code:
    RewriteEngine on
    RewriteBase /
    ReWriteRule \.htaccess [F]
    RewriteRule ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$ index.php?parent=$1&url=$2
    RewriteRule ^([a-zA-Z0-9\-]+)/?$ index.php?url=$1

  • #15
    Regular Coder
    Join Date
    Aug 2006
    Posts
    135
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a lot, both of you

    2 questions:
    1. What the [F] means?
    2. What this line means?
    Code:
    #IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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