Talantyyr Posted October 30, 2013 Share Posted October 30, 2013 Hi, I'd like to redirect www.mydomain.com to www.mydomain.com/startpage but only for www.mydomain.com without any page. e.g. www.mydomain.com/index.php should still work. How can this be achieved? Quote Link to comment https://forums.phpfreaks.com/topic/283446-rewrite-www-to-subfolder/ Share on other sites More sharing options...
requinix Posted October 30, 2013 Share Posted October 30, 2013 The request URI will be just a slash, so RedirectMatch ^/$ /startpage Quote Link to comment https://forums.phpfreaks.com/topic/283446-rewrite-www-to-subfolder/#findComment-1456255 Share on other sites More sharing options...
Talantyyr Posted October 31, 2013 Author Share Posted October 31, 2013 (edited) Thank you! I was messing around with RewriteCond and RewriteRule... ^^ Edit: Can i hide the /startpage somehow? So in this case, if you go to www.mydomian.com i don't want to show the /startpage in the browserbar... Edited October 31, 2013 by Talantyyr Quote Link to comment https://forums.phpfreaks.com/topic/283446-rewrite-www-to-subfolder/#findComment-1456319 Share on other sites More sharing options...
Talantyyr Posted October 31, 2013 Author Share Posted October 31, 2013 Seems i can't edit my post a second time.... :-/ This also redirects all subdomain's to /startpage... i only want to redirect www.domain.com. Quote Link to comment https://forums.phpfreaks.com/topic/283446-rewrite-www-to-subfolder/#findComment-1456331 Share on other sites More sharing options...
requinix Posted October 31, 2013 Share Posted October 31, 2013 You can "hide" it by doing rewriting instead of redirecting. And to match only that domain you need RewriteCond. RewriteCond %{HTTP_HOST} =www.domain.com RewriteRule ^/?$ /startpage [L] Quote Link to comment https://forums.phpfreaks.com/topic/283446-rewrite-www-to-subfolder/#findComment-1456390 Share on other sites More sharing options...
Talantyyr Posted November 5, 2013 Author Share Posted November 5, 2013 Thank you! But i still have another problem :- ( I'm using rewriting for more readable links: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> where do i have to put that exactly to get it to work? ( /startpage is a rewrite for the index.php ). It's no really working with my current rewrite code... Thank you for your patience Quote Link to comment https://forums.phpfreaks.com/topic/283446-rewrite-www-to-subfolder/#findComment-1457060 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.