2013-06-23 31 views
0

我的網址目前是這樣的:的.htaccess,使網址漂亮,但現在顯示在頁面上沒有內容

http://www.example.com/test

他們過去是這樣的:

http://www.example.com/post.php?post=test

這很好,但我的post.php頁面不再顯示任何內容,即它不顯示我的博客文章,標題和時間戳。

.htaccess看起來像這樣:

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] 

和我post.php中網頁看起來是這樣的:

<?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> 

我在做什麼錯?這是我的頭!讓我知道你是否需要更多信息。

+0

如果你試試這個代碼:'1重寫規則^([^/\。] *)/ * $ post.php中後= $ [L]' – vikingmaster

回答

1

你有一個小錯誤。前$ 1取下反斜線:

RewriteRule ^(.*)$ /post.php?post=$1 [L] 
+0

絕對完美的,謝謝?您! – Josh