Forum Moderators: phranque
I just started a new job, in fact, a place I used to work a couple of years ago. In the meantime, people have been playing with the web sites and now all pages are .php rather than .htm since they all have database feeds.
In the .htaccess file there is a line to redirect old links:
RedirectMatch 301 ^(.*)\.htm$ $1.php
It seems to work just fine. However, I do not really want to redirect the home page. With this command, it seems that any link to www.mysite.com is being redirected to www.mysite.com/index.php. I prefer not to have this, and have the index page just displaying as www.mysite.com/ -
is there a way to alter the redirect command to redirect only subpages, but leave the home page alone, unless the link is to index.htm, in which case redirect to index.php..?
Am I making sense? Thanks for any advise and have a nice day
Jamie
With this command, it seems that any link to www.mysite.com is being redirected to www.mysite.com/index.php.
The redirect is only affecting any request for a page that ends in htm. This part ( (.*)\.htm ) is taking the page name and storing the value to be reused. The htm part is not saved for later. This part ( $1.php ) is saying, give me the stored value, and stick a php on the end of it. The variable (.*) has been assigned to $1.
is there a way to alter the redirect command to redirect only subpages, but leave the home page alone, unless the link is to index.htm, in which case redirect to index.php..?
We need the redirect since we changed all our pages to .php, but I do not want the home page "http://www.widgets.com/" to redirect to "http://www.widgets.com/index.php".
I would like all links to the home page to be directed to "http://www.widgets.com/", including internal links - just I have read that having some links to / and some to "index.php" can lead to loss of rankings in SE's since they may be treated as 2 different pages.... I realise there is some debate about it.
So can I alter this line
RedirectMatch 301 ^(.*)\.htm$ $1.php
or add something that stops the home page redirecting..?
Thanks to you, Web Gods.