SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: mod rewrite

  1. #1
    SitePoint Addict Fire59's Avatar
    Join Date
    Aug 2003
    Location
    mn
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mod rewrite

    I'm trying to modify my url. Here's what i have in my .htaccess file.
    Code:
    RewriteEngine on
    RewriteRule ^/$ /index.php
    RewriteRule /([a-z]+) /index.php?pageName=$1
    Then in my index.php file i'm simply trying to test if it works by doing this:
    For an example if someone type in www.mywebsite.com/standard it should translate to: www.mywebsite.com/index.php?pageName=standard
    Code:
    <?php
    echo $_GET['pageName'];
    ?>
    It's not working for me, any suggestions?

  2. #2
    SitePoint Zealot sanka69's Avatar
    Join Date
    Apr 2003
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you trying to have it that anything that goes to rewrite.php is redirected to index.php?

  3. #3
    SitePoint Addict Fire59's Avatar
    Join Date
    Aug 2003
    Location
    mn
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sanka69
    Are you trying to have it that anything that goes to rewrite.php is redirected to index.php?

    Sorry about the confusion, i fixed the question

  4. #4
    SitePoint Addict Fire59's Avatar
    Join Date
    Aug 2003
    Location
    mn
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright i figured out some stuff, first off my server didn't allow .htaccess so i had to go in httpd.conf and changed that. Now let my try to explain myself again.

    I'm testing out mod_rewrite, i think it's somewhat working now.

    .htaccess code
    Code:
    ErrorDocument 404 /404.php
    RewriteEngine on
    RewriteRule /rewrite/([0-9]+) /rewrite.php?id=$1
    rewrite.php code
    Code:
    <?php
    include ("header.php");
    echo 'rewrite';
    echo $_GET['id'];
    include ("footer.php");
    ?>
    when i type in the following url www.mysite.com/rewrite/3 , I get the header and footer and the 'rewrite' echo but no $_GET['id'].

    I'm probably overlooking something.

  5. #5
    SitePoint Zealot sanka69's Avatar
    Join Date
    Apr 2003
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    unfortunately the re-write code I was going to suggest doesn't appear to work either. Did you take a look at the mod_rewrite on sitepoint?

    mod_rewrite: A Beginner's Guide to URL Rewriting

  6. #6
    SitePoint Addict Fire59's Avatar
    Join Date
    Aug 2003
    Location
    mn
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yea i looked at that. I think there's probably something wrong with my apache setting.

  7. #7
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fire59 you cannot start with a slash a rewriterule within .htaccess.
    So RewriteRule / won't have to be used within .htaccess.

    Try this:

    RewriteEngine on
    RewriteRule ^rewrite/([0-9]+)/?$ /rewrite.php?id=$1

    where ^ means start of string
    $ means end of string
    /? means trailing slash optional



    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03


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
  •