2017-01-13 11 views
0

我要刪除我的文件.php如果有人寫.php不工作是這樣的:如果用戶將.php =>不工作或重定向到home如何從URL中刪除.php,如果添加.php,則無法工作?

這是我.htaccess

www.example.com/home.php => www.example.com/home 

網址:

RewriteRule ^home$ home.php 
+1

這看起來像一個重複:HTTP://計算器。 com/questions/4026021/remove-php-extension-with-htaccess – MannfromReno

+2

[Remove .php extension with .htaccess]可能重複(http://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess ) – Croises

回答

0
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^\.]+)$ $1.php [NC,L] 

你的.htaccess

+0

並非所有,我想要特定的網址 – AboYousef16

0

內你必須有阿帕奇活躍mod_rewrite模塊

.htaccess文件:

<IfModule mod_rewrite.c> 
# Enable RewriteEngine 
RewriteEngine on 
RewriteBase/
RewriteCond% {SCRIPT_FILENAME}! -d 
RewriteCond% {SCRIPT_FILENAME}! -f 
  
# Rewrite URL requested by the user 
# IN: ID-NAME 
# Output: example.php? Id = ID 
RewriteRule^([0-9] +) \ - ([a-zA-Z0-9 -] *) $ example.php? Id = $ 1 
</ IfModule> 

問候