Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 10 of 10
  1. #1
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    I've recently prepared Apache with all its glory on Ubuntu. After a lot of struggling, mod_rewrite works. However, the rule:

    Code:
    RewriteEngine on
    RewriteRule ^try$ page.php
    And when I go to localhost/try, I get a not found, followed by

    Code:
    The requested URL /home/steax/public_html/test/to.php was not found on this server.
    But the page certainly exists. If I enter it into the address bar, I'm offered a download of the php page. Am I making a mistake here?
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Well, the two are unrelated. The latter is probably because you haven't set up the PHP mime type to be handled by mod_php. Something like:

    Code:
    AddType application/x-httpd-php .php
    The former is different. The weird thing about the former is that it seems to be redirecting to something totally unrelated. Anyway, try [minicode]RewriteRule ^/...$[/minicode] instead.

  4. #3
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    The mime type thing is odd, because directly opening the page (that is, through localhost) does work. It's offered as download because I'm giving it /home/steax/ etc, which is standard filesystem, right?

    It's purely a problem with the redirect, it seems. It's plain not redirecting properly... any chance why?
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  5. #4
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Wait... Yeah, if you're referring to it on the local filesystem it's not being served through Apache. That's completely different.

    Do you have any other redirects that might explain it?

  6. #5
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Nothing at all. The .htaccess file is just that. I have a feeling it has to do with apache's configuration... but its mostly default. I installed mod_rewrite the simplest way possible... Do you have any tutorials or anything for me to follow?
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  7. #6
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    I suspect you have a rewrite rule somewhere that you're not noticing. Double-check your Apache configuration files to make sure there aren't any there. There's no reason why it would randomly be rewriting to something you didn't specify. Alternatively, try using something other than `try' to see if that changes anything (in case it's some weird default, though I doubt it).

  8. #7
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Turns out if I specify the rule all the way to the localhost (like this:

    Code:
    RewriteEngine on
    RewriteRule ^something/$ http://localhost/~steax/test/index.php?bla=blabla
    It does work. However, the address bar URL changes as well - I thought this only happened with the [R] at the end... Where do I check for other files?
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  9. #8
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Yeah, that's because the second version has an absolute URI as its rewrite target, so it's automatically interpreted as an external URI and therefore a redirect.

    Try this:

    Code:
    RewriteEngine On
    RewriteRule ^something/$ /~steax/test/index.php?bla=blabla

  10. #9
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Shadowfiend - it WORKS! Wow! Why does that one work? This time it goes totally smoothly... Thanks a ton!
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  11. #10
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    I suspect it's a RewriteBase issue. The leading / on the rewrite makes sure that it's relative to the site root. I'm curious, though -- if this .haccess is in your ~steax directory, does the ^something/$ match /~steax/something/ or /something/? That'll probably point to whether it's a base directory issue or something more interesting.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 07:20 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com