I tried to make Laravel works on my environment (MAMP) but i'm stuck in this situation.
The index.php file of Laravel is into a subfolder called "public", so if I want to test my application I need to access it with this url http://localhost/laravel/public/
but I want access with http://localhost/laravel
I tried to set an htaccess with this rows but it doesn't work:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ public/$1
</IfModule>
I'm not sure that this htaccess can resolves this situation, I get a 404 generated by Lavarel.
You need to create a virtualhost. Dayle Ress covers this in the first chapter in his Laravel book: https://web.archive.org/web/20121013083457/http://daylerees.com/2012/03/25/laravel-getting-started/
Put .htacess file in root with code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
public is actually the part that should be your document root.
Related
I Have A shared host and i have made a laravel project and when i upload it to the host
i made a htaccess file to redirect all requests to publc/index.php
and it works very well and laravel project work good
when i create a sub domain and but some files in subdomain's folder and try to access it
i got a 500 Internal Server Error
when i contaced the support they told me that this error because the .htaccess that i made
i need help to solve this problem
this is the structure of my public_html folder
-public_html
|-laravelproject
|- Laravel Projct Files
|-subdomain
|-index.php
|-.htaccess
.htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^laravelproject/public
RewriteRule ^(.*)$ laravelproject/public/$1 [L]
</IfModule>
Since subdomain is other installation i think you should add
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^laravelproject/public
RewriteRule ^(.*)$ laravelproject/public/$1 [L]
RewriteCond %{REQUEST_URI} !^subdomain/public
RewriteRule ^(.*)$ subdomain/public/$1 [L]
</IfModule>
But im no .htaccess expert, hope it works!...
I'm trying to install a slim framework based webapp on a plesk server. The app is working fine in my WAMP server, but doesn't work in the web server. It must be a miss configuration of the server but I'm not able to find out which problem it could be.
In my app, I print $this->app->request->getRootUri(); to access the called URI and I get : /public for any URI.
My /httpdocs/.htaccess looks like that :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/index.php [L]
RewriteRule (.*) public/index.php/$1 [L]
</IfModule>
My /httpdocs/public/.htaccess looks like that :
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Any idea of what I could do in order to make my app work ?
In order to find the virtual path, slim use the pathInfo of the env variable, or script_name if slim is not installed in a sub folder. It should always be pathInfo.
So it is working fine on windows, but it is not working on linux if we don't put the project in a subfolder...
I want to setup cakephp 3.x solution inside WP website.
On my bluehost server, I have directory structure in public_html is as follows:
I want to access stagetribescrm directory and that directory contains Cakephp 3.x file structure.
.
Code Inside of public_html/stagetribescrm/.htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /stagetribescrm/
# RewriteRule ^$ webroot/ [L]
# RewriteRule (.*) webroot/$1 [L]
</IfModule>
Code Inside of public_html/stagetribescrm/webroot/.htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
And the problem with this code is that it couldn't load css and js files inside webroot folder's file.
Thanks.
Please check for rewrite module is turn on or not in bluehost server than
follow below link:
http://www.abhinavsood.com/install-cakephp-in-subdirectory-of-wordpress/
I have a Silex project. Works on localhost(using php.exe) but I've just transferred it to a subdirectory of an existing website. For example:
www.website.foo/silex/
On the site, because of funky existing routing, the silex app is symbolically linked in the webroot under a /silex/ folder, but is actually elsewhere in the filesystem. The index page works.
I wasn't using an .htaccess file, but I copied the one from the documentation, but it hasn't gotten me anywhere.
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /var/www/webroot/silex/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
I am at a complete loss as to why it doesn't work, let alone what to change to fix it.
Edited .htaccess
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /silex/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Question
Does the .htaccess file have to be in the root directory? Or is being in the application directory fine?
Your RewriteBase directive is wrong, its related to web root, not your filesystem structure, so just use RewriteBase /silex/
For some reason when I deploy my API using Restler's API Explorer (a fork of Swagger UI) to production it gives me a general 404 error when I load:
/api/explorer
When I am more explicit and state:
/api/explorer/index.html
It loads the framing for the page but then reports "404 : Not Found ../resources.json" in red text below the header:
I'm fairly certain there's something environmental flaring up as the same files locally work. I also checked the .htaccess file in the /api/explorer directory and it looks right to me:
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ index.html [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.html [QSA,L]
</IfModule>
Any help would be appreciated.
It turns out all the problems were down to a mod_rewrite problem. I'm still not 100% on WHY this problem showed up in one environment but not others with precisely the same httpd.conf and .htaccess. Oh well, the solution is to be explicit in the rewrite rule about your base url using the RewriteBase directive.
In the API directory I now have the following .htaccess file:
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /api
RewriteRule ^$ index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
In the API-Explorer directory I now have the following .htaccess:
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /api/explorer
RewriteRule ^$ index.html [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.html [QSA,L]
</IfModule>
In order to troubleshoot this problem one invaluable tip that I came across is turning on Apache's mod_rewrite logging.
# Adding logging for Rewrites
RewriteLog logs/rewrite.log
RewriteLogLevel 2
Put this in any globally scoped area of httpd.conf; I put it around the entries that were already there about logging but you can also just put it at the end if you like that better. In addition, the basics around rewrite troubleshooting includes (apologies if this basic):
make sure that your httpd.conf has AllowOverride All and Options FollowSymLinks set for the directories you serving Restler out of.
You can put all of the configuration into httpd.conf and avoid .htaccess files altogether (and it's a bit faster that way too) but if you do that remember that httpd.conf has absolute url referencing versus .htaccess's relative.
You can check the ReadMe file on the Restler Github page
https://github.com/Luracast/Restler-API-Explorer#readme
Did you add the 'Luracast\Restler\Resources' class to create resources.json at API Root?
In your own index.php, the addAPIClass section should look like this:
$r = new Restler();
$r->addAPIClass('Luracast\\Restler\\Resources'); //this creates resources.json at API Root
// ... your own addApiClass
$r->handle();
It is in the documentation under "Use", but I had trouble figuring this out as well...
Make sure you have cache directory with write permission in your api root