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.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16

Thread: mod_rewrite

  1. #1
    Senior Member Karloff's Avatar
    Join Date
    Oct 2005
    Posts
    744
    Member #
    11702
    can't get my head around this,

    how do i go about getting my pages to take the php off the end

    ie

    www.????.com/index.php into www.???.com/home/


    etc

  2.  

  3. #2
    Senior Member imagn's Avatar
    Join Date
    Jul 2007
    Location
    Los Angeles
    Posts
    156
    Member #
    15594
    Try this:
    RewriteRule ^([a-z-]+)/$ index.php [L]
    This will take any alpha string and call the index.php page

  4. #3
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Alternatively, make that:
    Code:
    RewriteRule ^([a-z-]+)/$ \1.php [L]
    And you should get something that'll make any string become _that string_.php. So /home would become /home.php, etc.

  5. #4
    Senior Member imagn's Avatar
    Join Date
    Jul 2007
    Location
    Los Angeles
    Posts
    156
    Member #
    15594
    Much better usage

  6. #5
    Senior Member Karloff's Avatar
    Join Date
    Oct 2005
    Posts
    744
    Member #
    11702
    back to this, sorry.

    still can't get it to click

    it have this as my .htaccess
    Code:
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^index/$ index.php [L]
    and my link looks like
    HTML Code:
    <a href="/index" title="home" id="nav_home">HOME</a>
    what am i doing wrong?

  7. #6
    ljm
    ljm is offline
    Senior Member ljm's Avatar
    Join Date
    Aug 2006
    Location
    Manchester, England
    Posts
    284
    Member #
    13684
    Liked
    1 times
    Try adding this before your RewriteRule, without altering your links:

    Code:
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
    You may need to fiddle with the RewriteRule a bit, also.

  8. #7
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Also make sure you include the trailing / on the rewrite rule. Probably adding a ? before the $ will do the trick (makes the trailing / optional).

  9. #8
    Senior Member Karloff's Avatar
    Join Date
    Oct 2005
    Posts
    744
    Member #
    11702
    is this what you ment shadow/ljm?
    Code:
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^index/?$ index.php/ [L]

  10. #9
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Yes, but without the / on the end of index.php:
    Code:
    RewriteRule ^index/?$ index.php [L]

  11. #10
    Senior Member Karloff's Avatar
    Join Date
    Oct 2005
    Posts
    744
    Member #
    11702
    did that but still not working

    linky


Page 1 of 2 1 2 LastLast

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 01:41 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com