4z3rty
4z3rty

Reputation: 43

Use a PHP router from a directory

I have a dedicated server with apache installed on it.

I have different websites in separated folders and I can access it like this: www.example.com/folder1 www.example.com/folder2 ...

But in a file, I use a framework (F3). The router creates a 404 error when I try something like www.example.com/f3/my/route How can I change this without creating an alias?

See my /f3/.htaccess :

# Enable rewrite engine and route requests to framework
RewriteEngine On

# Some servers require you to specify the `RewriteBase` directive
# In such cases, it should be the path (relative to the document root)
# containing this .htaccess file
#

RewriteBase /f3/

RewriteCond %{REQUEST_URI} \.ini$
RewriteRule \.ini$ - [R=404]

RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L,QSA]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

Thanks,

Romain

Upvotes: 0

Views: 359

Answers (1)

Steve
Steve

Reputation: 20469

In your .htacces file, add a rewritebase with the folder name:

RewriteBase /f3/

Upvotes: 1

Related Questions