2012-04-16 85 views
0

我需要的文件擴展名後直接做了一招需要幫助301 htaccess的RedirectMatch

http://www.your-name.dk/Whatever-url.php-Whatever 301 - >http://www.your-name.dk/Whatever.php

我嘗試這一個,但沒有奏效

RedirectMatch permanent (.*).php.* htt*://www.your-name.dk/$1.php 

回答

1

啓用了mod_rewrite和.htacess,然後將此代碼添加到DOCUMENT_ROOT下的.htaccess中:

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/

RewriteRule ^([^-]+)-[^.]+\.php-\1$ $1.php [L,NC,R=301] 
+1

不要忘記httpd.conf中的AllowOverride。這不會返回301狀態,您應該將R = 301添加到您的答案 – 2012-04-16 17:58:31

+0

@ Cyber​​-GuardEnterprise:同意,我完全錯過了現在編輯它的'R = 301'。 – anubhava 2012-04-16 18:29:19