SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard GoldFire's Avatar
    Join Date
    Oct 2002
    Location
    Oklahoma City, OK
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I am failing at mod rewrite, help please!

    Well currently I use ForceType to make my URLs look like http://domain.com/page/var1/var2, but my host has changed php to secure mode so I can't use .htaccess, and I have to make a file called php.ini and put mod rewrite in it to make it work like I had before. Well below is what I put in there, but the URL will only work like this:
    http://domain.com/page.php/var1

    PHP Code:
    RewriteEngine on
    RewriteRule 
    ^([a-zA-Z0-9]+)$ /profile.php?id=$

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    Siegen, Germany
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    RewriteEngine on
    RewriteRule ^([a-zA-Z0-9]+)/?([a-zA-Z0-9]*)/?$ /profile.php?id=$1&id2=$2 [L]
    so I can't use .htaccess, and I have to make a file called php.ini and put mod rewrite in it
    What? Never heard about it... the php.ini has nothing to do with apache in this case. The file to create is specified in httpd.conf (AccessFileName). And the standrad is
    AccessFileName .htaccess
    this has nothing to do with the php save mode.

  3. #3
    SitePoint Wizard GoldFire's Avatar
    Join Date
    Oct 2002
    Location
    Oklahoma City, OK
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I don't know, but that is what my host told me and I put what I have in the php.ini file in my public_html folder and it made the url like I said it did, but I want to know how to make that RewriteRule so that it won't have the .php.

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

    I don't know about your ISP but ...

    Code:
    RewriteEngine On
    RewriteRule $page/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/?$ profile.php?id=$1&id2=$2 [L]
    should work in your root .htaccess file.

    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 GoldFire's Avatar
    Join Date
    Oct 2002
    Location
    Oklahoma City, OK
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It still gives me a file not found error for http://domain.com/page/var1, and it still works for http://domain.com/page.php/var1.

  6. #6
    SitePoint Wizard Dean C's Avatar
    Join Date
    Mar 2003
    Location
    England, UK
    Posts
    2,906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    RewriteEngine On
    RewriteRule ^page/([0-9]+)/?$ page.php?id=$1 [L]
    Are you sure you're testing this correctly btw, that rule above works flawlessly for me on localhost

  7. #7
    SitePoint Wizard GoldFire's Avatar
    Join Date
    Oct 2002
    Location
    Oklahoma City, OK
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, that works to an extent, it makes the URL look like what I want, but now the following code does not give me the id number from the URL.

    PHP Code:
    $path explode("/",$_SERVER['PATH_INFO']);
    $id $path[1]; 


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
  •