2013-01-24 106 views
0

我試圖在.htaccess文件中使用以下代碼隱藏URL中的文件名。但文件名正在顯示。任何人都可以更正此代碼。在網址中隱藏文件名

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php 
RewriteCond %{REQUEST_FILENAME}\.html -f 
RewriteRule ^(.*)$ $1.html 
+1

沒有足夠的細節。什麼不工作? –

回答

0

您可以使用它。在這裏我給了靜態代碼。例如,我的文件名是testimonial.php,我將其更改爲testimonial.html。因此,在標籤鏈接中,您應該提供testimonial.html而不是testimonial.php。那麼它會正常工作。

Options -Indexes 
RewriteEngine on 

RewriteRule ^testimonial.html /testimonial.php [NC] 
RewriteRule ^aboutus.html /about_us.php [NC]