2014-07-27 29 views
0

您好我正在更新發票系統,我們不會使用/client-area/viewinvoice.php/?id=xx重定向任何http請求到/ client-area/viewinvoice /?id = xx基本上刪除php擴展。我們無法完全刪除它們,因爲有些頁面仍在使用它們。創建從viewinvoice.php /?id = xx到viewinvoice./?=xx的重定向?

你如何通過htaccess來做到這一點?

感謝您的幫助

+0

什麼是這裏的問題? – Sean

+0

更新的主要部分..希望通過htaccess完成此操作。 – tunerzedge

回答

0

把這個代碼在你DOCUMENT_ROOT/.htaccess文件.php去除:

RewriteEngine On 
RewriteBase/

# To externally redirect /dir/file.php to /dir/file 
RewriteCond %{THE_REQUEST} \s/+(?:index)?(.*?)\.php[\s?] [NC] 
RewriteRule^/%1 [R=301,L,NE] 

# To internally forward /dir/file to /dir/file.php 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC] 
RewriteRule ^(.+?)/?$ /$1.php [L] 
+0

感謝您的幫助,但這沒有奏效。它的Wordpress安裝是否重要? – tunerzedge

+0

是的,它很重要,你應該在你的問題中提到它。如果它是WP,那麼只有301規則將工作,如果它放在其他WP規則之前。 – anubhava

相關問題