December 13th, 2011, 05:45 AM
Redirect everything to single php file
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.
Options +FollowSymlinks RewriteEngine on RewriteRule ^([^/]+)/ index.php
When I try to open localhost/test, I get a 404 page
<?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); ?>
How can I achieve this?
December 13th, 2011, 12:12 PM
Your Rule requires a trailing slash.
December 13th, 2011, 06:19 PM
Maybe I am missing something simple but I believe I already had the trailing slash?
$_GET['path1'] is index.php/ and $_GET['REQUEST_URI'] is /join
RewriteRule ^/$ index.php
RewriteRule ^([^/]+)/?$ index.php?path1=$1
December 13th, 2011, 06:28 PM
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.