2013-01-16 92 views
0

當人們訪問mysite的,例如mysite.com/folder1/i-love-stackoverflow,我想顯示文件/home/myaccount/public_html/mysite.com/folder1/folder2/i-love-stackoverflow.htmlhtaccess的刪除文件擴展名和更改文件夾

我現在.htaccess文件中/home/myaccount/public_html/mysite.com/folder1/.htaccess是這樣的:

RewriteEngine On 
RewriteBase /folder1/ 
RewriteCond %{REQUEST_FILENAME}.html -f 
RewriteCond %{REQUEST_URI} !/$ 
RewriteRule (.*) $1\.html [L] 

但是這個htaccess文件只能刪除html擴展名。它只有當文件i-love-stackoverflow.htmlfolder1

任何人都可以幫助我呢?我對htaccess不是很熟悉。

預先感謝您!

回答

0

我註冊新的主機,現在沒有folder2。 .htaccess文件在/home/myaccount/public_html/。 Html文件/home/myaccount/public_html/folder1以下代碼適用於我

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{DOCUMENT_ROOT}/folder1/$1\.html -f 
RewriteRule ^(.*)$ /folder1/$1\.html [L]