I have a laravel app and my client needs to access it via subfolder (let's say clientdomain.com/laravelapp/). I have already moved the contents of laravel's /public/ folder to /laravelapp and setup the index.php file so it references the right path.
I ended up with the following structure:
- /public_html (webroot of the server)
- /myapp/ (this is the public folder that was inside the laravel project)
- /laravel-framework (this is the laravel project folder with controllers, views, vendors, etc)
It works ok when I access the main route (clientdomain.com/laravelapp), it shows views, images and everything ok. The problem is when I try to access a different route, it shows 404.
I can't manually setup the nginx conf file, but ISPConfig has a box for nginx directives.
What are the right directives for a setup like mine?
I thank you in advance.
Try to add this to box for nginx directives.
location / {
try_files $uri $uri/ /index.php?$args;
}
Related
I have a spring boot server that serves content from the public/ directory inside resources. When I do GET / I get the content of the index.html.
But I also have a subfolder inside public, let's call it foo, with another index.html. However when I do GET /foo I get 404, I need to access the index.html specifically. How can I make it return index.html for the subpath, without specifying it in the url?
I have Laravel 6 site to be going to live and my concern is my site also can be open from the /public so does that affect in SEO of a site? I don't want to change root's server.php to index.php or move all the files and folders of the public to root. Because that can be unsafe.
Hi there i have some stupid mistake in configuring laravel.
First of all, this is my structure of folder
i use shared-hosting service and i place my laravel app, vendor and bootstrap into lib folder outside the htdocs (public/public_html) folder
so basically:
var
public_html
www
lib
-app
-bootstrap
-vendor
i create two subdomain called console for client and panel for admin
so i could call the subdomain specific url to access the system
this two subdomain is placed inside the public_html
public_html
-console
-panel
Then i move the public folder from laravel original into console folder (subdomain) with all the content from public folder (index.php, .htaccess, etc.)
Console.myDomain.com is working perfectly.
Now i want to create the admin system from the panel.myDomain.com i have created the subdomain and place all assets files (css, js, etc.) and change the routes into:
Route::group(array('domain' => 'panel.myDomain.com'), function(){
Route::get('/', function()
{
return View::make('admin.index');
});
});
but the page only showing blank page, (the blank page is shown because i place index.php file without content inside the panel folder)
additional info i have setup the bootstrap/paths.php into 'public' => __DIR__.'/../../public_html/console'
and is it require to change?
what proper way to make the panel.myDomain.com execute the routes and showing the right blade i have made?
thank you.
I'm working on a larger Web based Project, that probably will have to handle a couple of hundred requests per minute in a later stage (or more).
I never worked with NGINX, but reading the comparisions with apache, it seems that I probably should go the NGINX route. Reading about it, I always see that '.htaccess' files are a lazy solution. Now, I would like to avoid relying on .htaccess files, but my question is how?
What I mean is - if .htaccess are considered the lazy, hacky solution, what exactly is the clean solution for this issues:
Redirecting all specific URL's (except for CSS / Images, and this stuff), to a single php file (by the way, does that have a performance impact, if a single file like index.php handles the URL's and includes the required templates? Should I avoid that, and split into dozens of files?)
Reading PHP Tags inside of CSS Files ("AddHandler application/x-httpd-php .css ...")
Another layer of login (.htaccess authentication, with that little popup window)
This are basically the three things I'm using .htaccess for. Especially the first one, basically makes the whole Application work at all.
But for this Project, I'm really trying to stay clean, and up-to-date, solution wise. What are my possibilities? Where could I increase my performance? And how can I solve the 3 mentioned problems, whitout using a .htaccess, to develop on NGINX?
Thank you very much for your time and effort.
In order to get the most out of nginx, you have to understand that it is not a web server (like Apache), but a proxy. In simple terms, it acts like a giant rule engine to pass stuff along to other applications based on pattern matching on requests.
So to run PHP with nginx, you need a separate server (or process) that runs PHP. This can be Apache, but PHP includes a FastCGI Process Manager (FPM).
Here is basic boilerplate to get you going:
server {
listen 80;
server_name www.example.com example.com;
access_log /var/www/www.example.com/logs/access.log;
error_log /var/www/www.example.com/logs/error.log;
root /var/www/www.example.com/public_html;
location / {
index index.html index.htm index.php;
auth_basic "Username Required";
auth_basic_user_file /etc/nginx/htpasswd;
}
location ~ (\.php|\.css)$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php;
}
}
Question is offtopic, but to help you:
http://nginx.org/en/docs/http/converting_rewrite_rules.html
http://www.anilcetin.com/convert-apache-htaccess-to-nginx/
I am using CodeIgniter Version 2.1 & trying to link assets like images,stylesheets, javascript files etc in my views by using, header.php:
<link href="<?php base_url();?>css/style.css" rel="stylesheet" />
my controller code, calls the view:
<?php
class Main extends CI_Controller{
public function index() {
$this->load->view('header');
}
The view file from which I am trying to load the asset is located
../application/views/header.php.
the css file is loaded:
../application/views/css/style.css
this does not work. I get 404 - Page not found error.then, I tried moving css/style.css outside ../application directory in webroot. To my surpise, having assets in webroot(outsite ../application/views) seems to work nicely.
Now,
My Question is
Is having our assets directly in webroot, outsite ../application directory right approach? If YES/NO, then why?
If having assets directly in webroot is a good idea, than should I move ../application/views directory in webroot as well? How?
PS: I am new to CodeIgniter framework, so unaware of the best practices
If you see this, the section where .htaccess is used to remove index.php from the urls, that has a rewrite condition:
RewriteCond $1 !^(index\.php|images|robots\.txt)
In this line, images is a folder that will be ignored while mod-rewriting. So, you can replace it by assets, put all your directly linking files there, and happily use them.
RewriteCond $1 !^(index\.php|assets|robots\.txt)
EDIT: my bad, hadn't seen the date the question was asked. nevertheless, should be useful for someone.
It is best to put your assets in the webroot folder. When requesting assest from the server (depending on your setup), it will start from the root directory and work it's way down.
http://yoursite.com/application/views/css/mystyles.css
if it's in the root you only need to go from there
http://yoursite.com/css/mystyles.css
Although it might be worth putting them all inside a folder (/assets) to keep them contained, as well as the ability to write a more effective rewrite rule (if you are trying to remove the index.php from the url) to ignore the single folder instead of all the individual folders (/css, /js, etc)
As for the views folder, it's best if you leave it in the application folder as CodeIgniter has a built in loader that automatically checks /application/views for the view file when you use the code $this->load->view('myview')
Although there are way to move the views folder, if you are new to CI it's probably best to leave it there for now.
For linking css you can do something like:
echo link_tag('css/mystyles.css');
Check this for ref: http://codeigniter.com/user_guide/helpers/html_helper.html