0

This is the architecture of my website :

/ app/ index.php ... libs/ lib1/ file.php lib2/ ... 

I need to access index.php by this url : domain.com/index.php

I tried this :

Options +FollowSymLinks RewriteEngine on RewriteCond %{REQUEST_URI} !(.*)app RewriteRule ^(.*)$ app/$1 [L] 

It works, but inside my index.php, I call for example :

include('../libs/lib1/file.php'); 

It's doesn't work because this path refer to root now...

And I can't access to domain.com/libs anymore, because it's looking for domain.com/app/libs.

How can I do ?

1
  • The include() shouldn't matter what the path the browser is using, something else is probably causing the problem. Commented Jul 9, 2015 at 14:35

1 Answer 1

1

The include() shouldn't care what the path the browser sees. That should be based on the local filesystem on the server. But your rules are affecting direct access to the libs, so try adding a few more conditions:

Options +FollowSymLinks RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^app/ RewriteRule ^(.+)$ app/$1 [L] RewriteRule ^$ app/index.php [L] 

This makes it so requests for existing files or content won't get routed through the app folder.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for your answer. But now if I go to domain.com it's not showing me domain.com/app
@Iseldore added another rule to handle that.
It doesn't work. For example, <link href="../libs/jquery-ui/css/jquery-ui.min.css" rel="stylesheet"> doesn't work because it goes up a level too high.
@Iseldore you're using relative links in your content (note this has nothing to do with php includes). You need to change your links to use absolute URL's if you're changing what the base URL is

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.