watsmyname Posted July 6, 2011 Share Posted July 6, 2011 Hello, I m having trouble redirecting my domain . Lets say i have the domain www.mysite.com. All I want is whenever user types my domain www.mysite.com or mysite.com they should redirect to www.mysite.com/landing_page.php. While www.mysite.com/index.php and all other pages should not redirect. I tried using RedirectMatch, but didnt work i got a redirect loop. Is there any way to do this using .htaccess ?? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/241201-redirect-a-domain-to-a-specific-page/ Share on other sites More sharing options...
cags Posted July 6, 2011 Share Posted July 6, 2011 Sticking something like this in a .htaccess file in your root directory should do the job... RewriteEngine On RewriteRule ^$ /landing_page.php [R=301,L] Alternatively you could consider renaming the landing_page.php to index.php and move the home page into www.mysite.com/home/ Quote Link to comment https://forums.phpfreaks.com/topic/241201-redirect-a-domain-to-a-specific-page/#findComment-1239155 Share on other sites More sharing options...
watsmyname Posted July 7, 2011 Author Share Posted July 7, 2011 Thanks a ton cags for the reply, that worked. I changed code you gave to RewriteEngine On RewriteRule ^$ /landing_page.php [NC,L] This shows me the url http://www.mysite.com/ instead of http://www.mysite.com/landing_page.php Quote Link to comment https://forums.phpfreaks.com/topic/241201-redirect-a-domain-to-a-specific-page/#findComment-1239414 Share on other sites More sharing options...
cags Posted July 7, 2011 Share Posted July 7, 2011 As far as I can remember NC stands for NoCase which basically means make the Regex pattern non-case sensitive. Since your Regex pattern is empty, there's not a great deal of point leaving that one in there. Glad you got it working though. Quote Link to comment https://forums.phpfreaks.com/topic/241201-redirect-a-domain-to-a-specific-page/#findComment-1239459 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.