Forum Moderators: phranque

Message Too Old, No Replies

Redirect mydomain.com/m/1 to mydomain.com/m/1.html

Pls help

         

suthra

6:16 am on Apr 3, 2006 (gmt 0)

10+ Year Member



Hi Guyz, iam trying to 301 redirect:

mydomain.com/m/1 to mydomain.com/m/1.html

The number is dynamic, like
mydomain.com/m/2 to mydomain.com/m/2.html
mydomain.com/m/3 to mydomain.com/m/3.html

How do i do it through .htaccess so that the urls automaticall redirects

Pls help

Thanks a lot

Sarathy.s

kadhumia flo

10:40 am on Apr 3, 2006 (gmt 0)

10+ Year Member



well you could make a directory called 1 and put inside index.php with script
<?
header("Location: [exsample.com...]
?>
or use mod_rewrite

or from cpanel

jdMorgan

3:25 pm on Apr 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you want a redirect or an internal rewrite? The answer depends on whether you want the search engines to list URLs with or without extensions. If you want them to list extensionless URLs, but you want those URLs to access files with a .html extension, then an internal rewrite is needed:

Internal rewrite in top-level directory .htaccess:


RewriteRule ^(m/[0-9]+)$ /m/$1.html [L]

External redirect in top-level directory .htaccess:

RewriteRule ^(m/[0-9]+)$ http://www.example.com/m/$1.html [R=301,L]

For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim