My urls currently look like this:
http://www.example.com/test
and they used to look like this:
http://www.example.com/post.php?post=test
That's great but my post.php page doesn't show any content anymore i.e. it doesn't show my blog post, title and time stamp.
My .htaccess
looks like this:
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+post\.php\?post=([^\s]+) [NC]
RewriteRule ^ %1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /post.php?post=/$1 [L]
and my post.php page looks like this:
<?php
require("controller.php");
$post = $_GET['post'];
$rows = show_post($post);
foreach($rows as $row): ?>
<h1><?php echo htmlspecialchars( $row['title'] )?></h1>
<p><?php echo $row['post'] ?></p>
<p>Published on <?php echo $row['stamp'] ?></p>
<?php endforeach; ?>
<p><a href="index.php">Return to home</a></p>
What am I doing wrong? This is doing my head in! Let me know if you need further info.
You have a small error. Remove the backslash before $1:
RewriteRule ^(.*)$ /post.php?post=$1 [L]