1

hi just wondering if this is possible, when you access my default site directory localhost/mysite I want to set the path to render localhost/mysite/view/ all my HTML pages will be rendered here just like a PHP MVC structure can do... is it possible with htacces?

I'm an absolute newbie so I apologize if you find this question somehow stupid.

1
  • 1
    It's not stupid so much as incomprehensible. I really have no idea what you want to achieve. Can you provide more detail?
    – womble
    Aug 15 '11 at 11:20
2

If I understand you correctly this should be in the parent directories .htaccess file:

<IfModule mod_rewrite.c>
# enable mod_rewrite
RewriteEngine On
# redirect to the view folder
RewriteRule    (.*) view/$1    [L]
</IfModule>

And this should be in the .htaccess file in the view folder:

<IfModule mod_rewrite.c>
RewriteEngine On
# check to make sure this isn't a file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
</IfModule>
2
  • 1
    If you place it in htaccess you will definitely have a rewrite loop with "500 Internal Server Error" displayed to the user.
    – LazyOne
    Aug 16 '11 at 0:48
  • Good point @LazyOne, That's what I get for not actually testing my solution. :-) I think the revised solution should work. Aug 16 '11 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy