htaccess if url contains string redirect to folder

Report
Question

Please briefly explain why you feel this question should be reported .

Report Cancel

I’m facing a hard time with my htaccess files and folder structure.
To expose the problem, my boss wants a website with this specific folder structure:

-/pages
--several.html pages here
-/account
--MVC file structure for the accounts area.
---/models
---/controllers
---/assets
---index.php
---.htaccess
-/orders
--fiveOrSix.php pages here
--index.php
-index.php
-.htaccess

Don’t get me wrong here, if I called the shots ( and tried to explain the benefits of it several times ), I’d make the mvc on the root folder and render all the pages but he’s being quite a bit inflexible on this point and as the engineer I’m there to solve any problem. Unfortunably, there were some problems, and today is Saturday , it’s 3 A.M. and I’m still trying to figure out how to do this instead of trying to get laid or something else that I don’t have oportunity to do during the week.

So, continuing:

As most of the mvc’s, I need to redirect all querys to index.php, so, I’d need and .htaccess file that when http://blah/account is called or /account/{something}, that request needs to be redirected to the account/index.php file.

What I’ve tried:

root .htaccess file:
RewriteEngine on

#RewriteCond %{REQUEST_URI} account
#RewriteRule .* account/index.php
#RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
#RewriteCond %{QUERY_STRING} account [OR]
#RewriteCond %{REQUEST_URI} account
#RewriteRule ^(.*)$ account/index.php?q=$1 [L,QSA]
#RewriteRule ^ http://83answers.com/? [L,R=301] <- this one actually came in a search on stack overflow

#RewriteRule ^(.*)account(.*)$ http://your.website.com [R=301,L] <!- this one also

#RewriteRule account http://localhost:8000 [R,L]

#RewriteCond %{QUERY_STRING} account
#RewriteRule .? http://83answers.com [R,L]

account .htaccess file: (this one was perfect when the mvc is on the root folder)

RewriteEngine on

RewriteCond %{REQUEST_URI} !/unit_tests
RewriteCond %{REQUEST_URI} !/www
RewriteRule ^(.*)$ framework/index.php?q=$1 [L,QSA]

So, in short: if the url contains /account or /account/{something} it needs to load /account/index.php else, loads anything that’s asked.

If someone can give me an hand on this I’ll be really thankfull.

Thanks in advance.

PS: Sorry my rusty english, and if this question was too long.
PS2: I’ve kept the mvc filestructure short just to give an hint of the project. Just said that because sometimes, people instead of contributing to the question, just point out this details.
PS3: the .htaccess file full of # was from the attempts I’ve made ( I didn’t delete them to keep track of every try I’ve made to this point )

0
0 Answer 33 views 0