#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    37
    Rep Power
    3

    Redirect everything to single php file


    Hello everyone,
    I am running Vista, Apache 2.2 and PHP 5.38 on my development machine. I want to build a site where each request is redirected to index.php, and that will take care of the processing..

    I have mod_rewrite module loaded in Apache.

    .htaccess:
    PHP Code:
    Options +FollowSymlinks RewriteEngine on RewriteRule ^([^/]+)/ index.php 
    index.php:
    PHP Code:
    <?php $address=$_SERVER['PHP_SELF']; $output=""$output+="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"link\"><html xmlns=\"link\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>123</title></head><body>"$output+=$address$output+="</body></html>"; print($output); ?>
    When I try to open localhost/test, I get a 404 page

    How can I achieve this?

    Cheers
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,993
    Rep Power
    9397
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    37
    Rep Power
    3
    Maybe I am missing something simple but I believe I already had the trailing slash?

    Code:
    Options +FollowSymlinks
    RewriteEngine on
    RewriteRule ^/$ index.php
    RewriteRule ^([^/]+)/?$ index.php?path1=$1
    $_GET['path1'] is index.php/ and $_GET['REQUEST_URI'] is /join
  6. #4
  7. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,993
    Rep Power
    9397
    If the URL does not have a trailing slash then the RewriteRule you have there will not match it and it won't get rewritten.

IMN logo majestic logo threadwatch logo seochat tools logo