rewrite a URL

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
sugith_k
Forum Newbie
Posts: 2
Joined: Sun Jan 17, 2010 11:10 pm

rewrite a URL

Post 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
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: rewrite a URL

Post 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']);
    }
?>
 
sugith_k
Forum Newbie
Posts: 2
Joined: Sun Jan 17, 2010 11:10 pm

Re: rewrite a URL

Post 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
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: rewrite a URL

Post by pbs »

Try this
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
Post Reply