2016-10-02 114 views
0

我有一個URL(Example.com/blog/)和blog是我的網站根目錄。 blog包含一個index.php文件,該文件根據查詢字符串?url=[some url]生成一個頁面,例如example.com/blog/?url='hello-world'是一個可以生成信息的有效查詢字符串。我想這個網址是example.com/blog/hello-worldSEO友好的URL不起作用

目前,我有一個全球.htaccess文件,刪除所有擴展名。在我的博客目錄裏面是另一個.htaccess文件。我嘗試將URL更改爲友好的URL:

RewriteEngine on 
RewriteBase /blog/ 
RewriteCond %{REQUEST_FILENAME} -f 
RewriteRule ^(blog)/(.*)$ blog/index.php?url=$2 

不幸的是,這是行不通的。我如何解決這個問題,以便友好的URL顯示?

回答

2

試試這個像這樣,

RewriteEngine on 
RewriteBase /blog/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /blog/?url=$1 [QSA,NC,L] 
+0

出於某種原因,我得到了500內部服務器錯誤與此 – user2896120

+0

請現在就來試試!實際上有$ 1而不是$ 2,因爲我們只有一個匹配組。 –

+0

嗯,這仍然顯示500錯誤 – user2896120