SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard Dean C's Avatar
    Join Date
    Mar 2003
    Location
    England, UK
    Posts
    2,906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Subdomains with mod_rewrite

    Information

    • I have a subdomain: lala.example.com which points to example.com/somedir
    • I have a .htaccess file within my example.com/somedir which contains:

      Code:
      RewriteEngine On
      RewriteRule ^([0-9A-Za-z\-\/]+)/?$ cat.php?p=$1 [L]
    • When I go to lala.example.com it loads the correct index.php file which resides within example.com/somedir
    • When I go to lala.example.com/StupidDir it gives me a 404 saying that the file doesn't exist (cat.php that is).


    So from the above information I'm assuming mod_rewrite works a lot different when used with subdomains ?

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,650
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Dean,

    WHAT DIRECTORY is cat.php located in?

    Just remember that Apache thinks it's in the lala subdomain and knows NOTHING of example.com so, if cat is located in example.com's DocumentRoot then it's OUTSIDE the webspace of lala.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Wizard Dean C's Avatar
    Join Date
    Mar 2003
    Location
    England, UK
    Posts
    2,906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cat.php is located in example.com/somedir

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,650
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Dean,

    Hmmm, someone else (lilliman?) found a similar subdirectory problem.

    Would you please try changing the RewriteRule to eliminate the escapes (which are NOT required in the square brackets):

    RewriteRule ^([0-9A-Za-z/-]+)/?$ cat.php?p=$1 [L]

    Then see what happens when you get rid of the optional slash, too?

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  5. #5
    SitePoint Wizard Dean C's Avatar
    Join Date
    Mar 2003
    Location
    England, UK
    Posts
    2,906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I get the same problem The thing is when I go to lala.example.com/cat.php it loads. I've even tried putting the full path /var/www/html/somedir in my rewriterule to no effect

  6. #6
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,650
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Dean,

    It the URL retaining lala.example.com? If so, an e-mail to Apache.org might be in order (they can't fix it if they "don't know it's broke").

    Do you have some overriding action directed by www.example.com's mod_rewrite? If you have redirects in there, turn them off (for a test only) with RewriteEngine Off before your rewrite rules.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  7. #7
    SitePoint Wizard Dean C's Avatar
    Join Date
    Mar 2003
    Location
    England, UK
    Posts
    2,906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the end I managed to find a solution after spending the last hour on google. I had to use RewriteBase /

    I'd tried RewriteBase full/path/to/it

    Silly how it's something so silly eh

  8. #8
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,650
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Dean,

    Hmmm, you mean that directive actually does something useful? Horrors!

    Okay, if that's in the lala directory AND called as part of the lala subdomain, then I guess it's use is to remind Apache of those facts - to anchor it there!

    Thanks for that feedback!

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


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
  •