2012-04-16 83 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