RewriteRule for 301 redirects

I looked through all the response threads for the rewrite rule issue. Tried suggestions, but I still don't know what I'm doing wrong.

I want to do 301 redirects of our old URLs to new ones. Example:

old url : http://www.xyz.com/abc/topics.html new url : http://www.xyz.com/index.php#first 

I try to follow the rule in .htaccess:

 RewriteEngine on RewriteRule ^\/abc\/(.+)$ http://www.xyz.com/index.php#first [L,R=301] 

Any advice is welcome

+7
source share
2 answers

Try:

 RewriteRule ^abc\/(.+)$ http://www.example.com/index.php#first [L,R=301, NE] 
+19
source

You can, of course, do this with "mod_rewrite", but in this situation, I suggest you use mod_alias as it is faster and easier (see this SO answer: mod_rewrite or mod_alias? )

Like this:

 Redirect permanent /abc http://www.xyz.com/index.php#first 
+4
source

All Articles