2015-11-11 84 views

回答

1

嘗試這種在.htacess

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteRule ^([^/]+)\.php/$ $1.php 
    RewriteRule ^([^/]+)\.html/$ $1.html 
</IfModule> 

試圖.htacess 之前,請一定要改變apache2.conf

的查找和替換AllowOverride NoneAllowOverride All<Directory>指令指向您的公共網頁,其中htaccess文件駐留

如果你使用Ubuntu,你可以找到apache2.conf路徑/etc/apache2/apache2.conf

<Directory /var/www/> 
Options Indexes FollowSymLinks 
AllowOverride All 
Require all granted 
</Directory> 

這裏/var/www/下是你.htacess所在

編輯路徑: 一種更好的方式,通過@hjpotter的意見建議

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteRule ^(.+)\.(php|html)/$ $1.$2 
</IfModule> 
+1

單'重寫規則^( 。+)\。(php | html)/ $ $ 1. $ 2'就足夠了。 – hjpotter92

+0

謝謝你,先生:)我也是一個初學者,編輯答案,因爲你建議:) –

+0

謝謝你! :D – user3387682