2013-02-19 110 views
0

我有一個文件夾命名爲我的網站「關鍵詞」,像這樣的:http://www.mysite.com/keywords/顯示索引頁面所有鏈接到文件夾

在文件夾我只有一個index.php文件。無論在文件夾後面輸入什麼內容,我都需要index.php來顯示。例如,http://www.mysite.com/keywords/this-is-a-test應顯示index.php文件的內容,但不更改URL。

我試過的一切似乎都失敗了 - 我正在使用我的/關鍵字/文件夾中的.htaccess。無論我在那裏放置什麼,我似乎都不斷收到404錯誤。任何幫助將不勝感激,我敢肯定,這是一個小而簡單的事情,我只是不知道該怎麼做。

這是我目前有:

RewriteEngine on 
RewriteRule - index.php [L] 

這裏的問題是,它只能與他們破折號去鏈接時工作。

例如,

http://www.mysite.com/keywords/testing-this 

確實工作。但這是行不通的:

http://www.mysite.com/keywords/testingthis 

任何幫助,將不勝感激。

回答

0
RewriteEngine On 
RewriteBase/ #make sure your website is located in root directory, if not you have to add directory here... 
RewriteRule ^keywords/testingthis$ /keywords/index.php$1 [L] 
0

你可以試試這個:

Options +FollowSymlinks 
RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_URI} !index\.php [NC] 
RewriteCond %{REQUEST_URI} ^/keywords/.+ [NC] 
RewriteRule .*  keywords/index.php [L] 

地圖默默:

http://www.mysite.com/keywords/anything

要:

http://www.mysite.com/keywords/index.php

沒有任何內容傳遞給index.php,因爲OP沒有在問題中提到該要求。

字符串keywords被假定爲固定的,而anything被假定爲動態的。

anything必須至少保留一個字符才能應用規則。

對於永久和可見重定向,請將[L]替換爲[R=301,L]

相關問題