Help using mod_rewrite
Posted: Fri Jul 24, 2009 8:37 am
I'm using a tutorial (link) to help me understand how to use mod_rewrite so I can have more control over my webpage + links. But I'm having some issues with this basic mod_rewrite script.
.htaccess code
index.php code
Now I have a directory listing like "http://www.insight.atbhost/mime_test/page/software" I have both index.php and .htaccess files in the mime_test folder and when I go to access the software folder it works and I get an echo saying: The requested page was: software. The problem is, the link in the address bar is still showing "http://www.insight.atbhost/mime_test/page/software" instead of "http://www.insight.atbhost/index.php?page=software" like I want it too.
I can also get different reading from the echo statement also. For example, if I change the "/mime_test/page/software" to "/mime_test/page/hardware" even if the hardware folder doesn't exists it still echoes The requested page was: hardware.
It also does the same if I manually put in /mime_test/index.php?page=software or /mime_test/index.php?page=hardware etc etc. It also doesn't load the index.php from those folders which I also want.
Can somebody please explain what I'm doing wrong?
.htaccess code
Code: Select all
RewriteEngine on
RewriteRule ^page/([^/\.]+)/?$ index.php?page=$1 [L]Code: Select all
<html>
<head>
<title>Second mod_rewrite example</title>
</head>
<body>
<p>
The requested page was:
<?php echo $_GET['page']; ?>
</p>
</body>
</html>I can also get different reading from the echo statement also. For example, if I change the "/mime_test/page/software" to "/mime_test/page/hardware" even if the hardware folder doesn't exists it still echoes The requested page was: hardware.
It also does the same if I manually put in /mime_test/index.php?page=software or /mime_test/index.php?page=hardware etc etc. It also doesn't load the index.php from those folders which I also want.
Can somebody please explain what I'm doing wrong?