1

I've looked everywhere for an htaccess rule that can rewrite a url from:

customer.com/it/public/ to customer.com/it/

My folder structure is like this:

/customer.com .htaccess |-- it |-- .htaccess |-- public | |-- .htaccess 

Inside the root of the website, is a Codeigniter app, and inside the IT folder, there is a Laravel app.

This is my current HTACCESS in the root of my website (rewrites the codeigniter index.php):

<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT,L] </IfModule> 

These are the rules in my HTACCESS file in the root of the IT folder (supposed to rewrite laravel public folder):

<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_URI} !^public/ RewriteRule ^(.*)$ /public/$1 [L] </IfModule> 

And these are the rules inside the HTACCESS file in the Public folder (rewrites the index.php inside the public folder):

<IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On # Redirect Trailing Slashes... RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule> 

Portion of the debug:

DOCUMENT_ROOT C:/xampp/htdocs REQUEST_SCHEME http CONTEXT_PREFIX CONTEXT_DOCUMENT_ROOT C:/xampp/htdocs SERVER_ADMIN postmaster@localhost SCRIPT_FILENAME C:/xampp/htdocs/it/public/index.php REMOTE_PORT 44461 REDIRECT_URL /it/ GATEWAY_INTERFACE CGI/1.1 SERVER_PROTOCOL HTTP/1.1 REQUEST_METHOD GET QUERY_STRING REQUEST_URI /it/ SCRIPT_NAME /it/public/index.php PHP_SELF /it/public/index.php REQUEST_TIME_FLOAT 1395338241.106 REQUEST_TIME 1395338241 

1 Answer 1

0
RewriteRule ^(.*)$ /public/$1 [L] 

This line produces an absolute substitution, so mod_rewrite does not add back the directory prefix ("it" in this case). Try to replace that rule with the following:

RewriteRule ^(.*)$ public/$1 [L] #relative substitution 

or with this:

RewriteRule ^(.*)$ /it/public/$1 [L] #absolute substitution including dir prefix 

PS: You don't really want to rewrite "/it/public/" to "/it/", rather the opposite.

EDIT: Also, remove the "redirect trailing slashes" rule.

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

3 Comments

This definitely did something. Instead of a codeigniter 404 page I get the laravel 404 error page when I try customer.com/it. Are there paths I need to configure in laravel to allow it to run in a subfolder?
If /bootstrap/paths.php is properly configured, it should work. Could you post the debug message?
I haven't changed them, their the stock paths. But it doesn't seem like I need to since they just look for the directory above which is indeed correct. This is what's returned for __DIR__ : C:\xampp\htdocs\it\bootstrap, which is correct. I'll see what I can do

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.