Page 1 of 1

rewrite a URL

Posted: Sun Jan 17, 2010 11:18 pm
by sugith_k
Hi,
I would grateful if someone can help me with this matter.
I have a URL and I want to redirect it to the index.php.

This is the URL
http://www.smslanka.com/index.php?optio ... view=reset

and I want to redirect that to the
http://smslanka.com/index.php

Please if you know about this matter write to me as soon as possible.

Regards,
Sugith Karunatahne
http://www.eyepax.com

Re: rewrite a URL

Posted: Mon Jan 18, 2010 12:13 am
by pbs
You can try this code, put it in top of the page.

Code: Select all

 
<?php
    if (strstr($_SERVER['HTTP_HOST'],"www."))
    {
        header("Location:http://".$_SERVER['HTTP_HOST']."/?".$_SERVER['QUERY_STRING']);
    }
?>
 

Re: rewrite a URL

Posted: Mon Jan 18, 2010 1:09 am
by sugith_k
can you tell me how do I have to fix that using the .htaccess file.
I used this code in the htaccess file but it didn't work.

Redirect 301 ^index.php?option=com_user&view=reset$ http://abc.com/index.php

Regards,
Sugith Karunaratne
http://www.eyepax.com

Re: rewrite a URL

Posted: Mon Jan 18, 2010 2:54 am
by pbs
Try this
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]