+ Reply to Thread
Results 1 to 8 of 8

Thread: Help rewriting /index.php to /index

  1. #1
    leafypiggy's Avatar
    leafypiggy is offline Community Advocate leafypiggy is on a distinguished road
    Join Date
    Aug 2007
    Location
    Massachusetts
    Posts
    2,228

    Help rewriting /index.php to /index

    Hey y'all,

    I'm using mod_rewrite in apache, and I can't seem to get this code to work. FreeNode was unhelpful as usual, seeing as they're all full of themselves and think they know everything and are just plain a pain in the butt.

    Anyways: Here's my code.

    Mod_rewrite is enabled (a2enmod rewrite), and I'm logging it to /var/log/apache2/rewrite.log (at RewriteLogLevel 9):

    Code:
    Options +FollowSymLinks
    Options +Indexes
    RewriteEngine on
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^([^\.]+)$ $1.php [NC,L]
    Nothing's in the log file.

    Basically, that script should just take file.php, and make it just file. (in the browser.

    Link is: http://bakon.neilhanlon.com/vizoxidy/index.php
    Neil Hanlon | x10Hosting Support Representative
    Neil[at]x10hosting.com
    █ I'm always happy to help. Just ask a question in Free Hosting
    Terms of Service IRC

  2. #2
    espfutbol98's Avatar
    espfutbol98 is offline x10 Sophmore espfutbol98 is an unknown quantity at this point
    Join Date
    Apr 2009
    Location
    Zagreb... želim
    Posts
    200

    Re: Help rewriting /index.php to /index

    Here's what I use on my site and it workes like a charm. It references /[whatever] to [whatever].php and if it can't find it, it shows, in this case, error.php
    Code:
    RewriteCond %{DOCUMENT_ROOT}/$1.php -f
    RewriteRule ^/?(.*)$    $1.php 
    RewriteRule ^/?error\.php - [L]
    Last edited by espfutbol98; 03-22-2010 at 08:00 PM.

  3. #3
    leafypiggy's Avatar
    leafypiggy is offline Community Advocate leafypiggy is on a distinguished road
    Join Date
    Aug 2007
    Location
    Massachusetts
    Posts
    2,228

    Re: Help rewriting /index.php to /index

    Still nothing.. Nothing in rewrite.log either...

    Anyone else care to offer their opinion?
    Neil Hanlon | x10Hosting Support Representative
    Neil[at]x10hosting.com
    █ I'm always happy to help. Just ask a question in Free Hosting
    Terms of Service IRC

  4. #4
    leafypiggy's Avatar
    leafypiggy is offline Community Advocate leafypiggy is on a distinguished road
    Join Date
    Aug 2007
    Location
    Massachusetts
    Posts
    2,228

    Re: Help rewriting /index.php to /index

    Doesn't work on an x10 server either.. so it's not my server that's the issue.
    Neil Hanlon | x10Hosting Support Representative
    Neil[at]x10hosting.com
    █ I'm always happy to help. Just ask a question in Free Hosting
    Terms of Service IRC

  5. #5
    leafypiggy's Avatar
    leafypiggy is offline Community Advocate leafypiggy is on a distinguished road
    Join Date
    Aug 2007
    Location
    Massachusetts
    Posts
    2,228

    Re: Help rewriting /index.php to /index

    With the help of lemon-tree, I've figured it out.

    Code:
    DirectoryIndex index
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^index.php$ /vizoxidy/index [R]
    <FilesMatch index>
            ForceType application/x-httpd-php
    </FilesMatch>
    Copied index.php to index (and deleted index.php)

    Then set it to force a particular MIME type to certain files.

    Next, we redirected index.php to index.

    Then we added a DocumentRoot.

    And finally, I went to go rub it in #httpd's face.. but I forgot I was banned from that channel. =/
    Neil Hanlon | x10Hosting Support Representative
    Neil[at]x10hosting.com
    █ I'm always happy to help. Just ask a question in Free Hosting
    Terms of Service IRC

  6. #6
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Help rewriting /index.php to /index

    As an alternative, you can turn on content negotiation with the Apache config line Options +MultiViews.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  7. #7
    leafypiggy's Avatar
    leafypiggy is offline Community Advocate leafypiggy is on a distinguished road
    Join Date
    Aug 2007
    Location
    Massachusetts
    Posts
    2,228

    Re: Help rewriting /index.php to /index

    I'd heard that mentioned in #httpd yesterday...

    Didn't work, but lemon-tree and I diagnosed that it was because I had AllowOverride None set in my vhost.. so.. I'll try it.

    Edit:

    Works! Much simpler than what I did.
    Last edited by leafypiggy; 03-23-2010 at 05:39 PM.
    Neil Hanlon | x10Hosting Support Representative
    Neil[at]x10hosting.com
    █ I'm always happy to help. Just ask a question in Free Hosting
    Terms of Service IRC

  8. #8
    eric_wu619 is offline x10Hosting Member eric_wu619 is an unknown quantity at this point
    Join Date
    Dec 2009
    Posts
    2

    Re: Help rewriting /index.php to /index

    thanks

+ Reply to Thread

Similar Threads

  1. index.html works, index.php does not.
    By masalon in forum Free Hosting
    Replies: 7
    Last Post: 08-11-2009, 08:09 PM
  2. Use of index.aspx as an index page?
    By akjcorps in forum Free Hosting
    Replies: 7
    Last Post: 05-29-2009, 11:02 AM
  3. will not go to my index.php
    By kambuja in forum Free Hosting
    Replies: 6
    Last Post: 02-06-2009, 09:09 PM
  4. index.php
    By quangphangbang in forum Free Hosting
    Replies: 4
    Last Post: 12-05-2007, 05:52 PM
  5. Index.php instead of Index.html
    By GamingX in forum Free Hosting
    Replies: 5
    Last Post: 09-20-2007, 07:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers