2013-06-05 59 views
0

此刻,我已在我的WordPress的.htaccess文件如下:如何在我的wordpress htaccess文件中刪除外部文件的擴展名?

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 

# END WordPress 

我上傳稱爲contact.php一個單獨的PHP文件,我想重寫,使用戶可以通過訪問http://mydomain.com/contact代替http://mydomain.com/contact.php

什麼,我需要把我的.htaccess文件,以便我能有這樣的重寫僅此一個文件?

回答

2

只需添加一行爲您重定向,如下圖所示:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^contact$ /contact.php [L] <-- New Line 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 

# END WordPress 
+0

感謝 - 這正是我需要:-) – alimac83

1

您應該# BEGIN WordPress評論之前把這個,因爲它不是WP相關:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^contact$ /contact.php [L] # /contact rewrite 
</IfModule> 

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 

# END WordPress 
相關問題