简体   繁体   中英

htaccess 301 redirection issue

Regarding 301 redirection, how can I redirect from one URL to another?

From:  http://www.xyz.com/abc.php%0D%0A
To: only url and abc.php

Using .htaccess it does not working.

Redirect 301 /abc.php%0D%0A http://www.xyz.com/abc.php

Please advice. Is it possible or not?

You need to use RedirectMatch that supports regex:

RedirectMatch 301 ^/(abc\.php).*$ /$1

OR else you can use mod_rewrite .

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On
RewriteRule ^(abc\.php).*$ /$1 [L,NC,R=301]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM