sasori Posted August 22, 2013 Share Posted August 22, 2013 (edited) here's the structure of the app htdocs somefiles myfolder /image /js index.html style.css protected /models /controllers /blahblabha index.php .htaccess what i want to happen is any stuff that I type after my domain name, should get redirected to the /myfolder like e.g www.mydomain.com -> www.mydomain.com/myfolder (with or without www) www.mydomain.com/blahblahbalh -> www.mydomain.com/myfolder (with or without www) dev.mydomain.com/omghowtodothis -> www.mydomain.com/myfolder (with or without www) http://www.mydomain.com/help-me-please-/how-to-do-this -> www.mydomain.com/myfolder(with or without www) so how to do that in .htaccess ? at first i tried this RewriteEngine On RewriteCond %{HTTP_HOST} ^(http://www.)?mydomain.com$ RewriteCond %{REQUEST_URI} ^/(.*)+$ RewriteRule (.*) http://dev.mydomain.com/$1 [R=301,L] RewriteRule ^$ /myfolder [L,R=301] but it wasn't able to cater for the stuffs that i typed after the main domain URL such as in my example above Edited August 22, 2013 by sasori Quote Link to comment https://forums.phpfreaks.com/topic/281466-how-to-redirect-all-urls-of-the-main-domain-to-a-subfolder/ Share on other sites More sharing options...
jazzman1 Posted August 22, 2013 Share Posted August 22, 2013 (edited) This will redirect every directory request which not contains a file itself. For instance /folder1, /folder2 but not /folder1.display.php Try, Options -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ /myfolder [QSA,L,R=307] By the way, do you know any good online resource where I can watch "Naruto" with good quality? Edited August 22, 2013 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/281466-how-to-redirect-all-urls-of-the-main-domain-to-a-subfolder/#findComment-1446277 Share on other sites More sharing options...
sasori Posted August 22, 2013 Author Share Posted August 22, 2013 This will redirect every directory request which not contains a file itself. For instance /folder1, /folder2 but not /folder1.display.php Try, Options -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ /myfolder [QSA,L,R=307] By the way, do you know any good online resource where I can watch "Naruto" with good quality? it says, page not redirecting properly...your suggested code , didn't worked at all, any other ideas how to solve this thing ? OFF TOPIC : here http://narutobase.net/Naruto-Shippuden-Episodes.html if you know the episode number , you can just browse youtube every weekend. Quote Link to comment https://forums.phpfreaks.com/topic/281466-how-to-redirect-all-urls-of-the-main-domain-to-a-subfolder/#findComment-1446344 Share on other sites More sharing options...
jazzman1 Posted August 22, 2013 Share Posted August 22, 2013 ......your suggested code , didn't worked at all I really like that So according your topic: www.mydomain.com -> will be redirected to -> www.mydomain.com/myfolder www.mydomain.com/blahblahbalh -> will be redirected to -> www.mydomain.com/myfolder dev.mydomain.com/omghowtodothis ->will be redirected to -> www.mydomain.com/myfolder So can you be more specific, please? Or....which part of the code doesn't work? Thank you for the link above Quote Link to comment https://forums.phpfreaks.com/topic/281466-how-to-redirect-all-urls-of-the-main-domain-to-a-subfolder/#findComment-1446355 Share on other sites More sharing options...
Solution sasori Posted August 23, 2013 Author Solution Share Posted August 23, 2013 nevermind , it got solved by just using header("Location: to my chosen directory"); exit; But i don't know why or how no matter what pattern I used in the .htaccess, all the stuff that was typed after the slash of the main domain, shows "url not found in server", maybe it's with the framework........moving on, atleast it got solved now without using .htaccess, thanks for the time though... Off Topic: by the way,I suggest you read the manga version of the naruto, it's more advance than the cartoon series www.mangastream.com Quote Link to comment https://forums.phpfreaks.com/topic/281466-how-to-redirect-all-urls-of-the-main-domain-to-a-subfolder/#findComment-1446412 Share on other sites More sharing options...
jazzman1 Posted August 23, 2013 Share Posted August 23, 2013 He-he, I just forgot to add a dollar sign in my script here Change: RewriteRule ^ /myfolder [QSA,L,R=307] to RewriteRule ^$ /myfolder [QSA,L,R=307] Off Topic: by the way,I suggest you read the manga version of the naruto, it's more advance than the cartoon series www.mangastream.com I will Quote Link to comment https://forums.phpfreaks.com/topic/281466-how-to-redirect-all-urls-of-the-main-domain-to-a-subfolder/#findComment-1446421 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.