My folders structure like this: app, bootstrap, public, vendor
But, I want to create another folder in there and put some php files (irrelevant with laravel).
For example wordpress.
i.e.
I have a web site with laravel and I want a wordpress blog in subfolder to.
I created folder names like "blog". But when I access domain.com/blog laravel presents an error.
I need to tell laravel, blog folder is not yours.
How can I do that?
I made like this:
RewriteEngine On
RewriteCond $1 !^(chat)
and it's work
RewriteEngine On
RewriteRule ^(blog)($|/) - [L]
Related
i need to upload laravel project on sub folder in subdomain because there will be wordpress website,
while i am searching i found that i can use .htaccess, is there another way ? because i am new to laravel and no experience in [tag:.htaccess ]
--- subdmoain.com
--- public_html
--- subfolder
---laravel project
i tried using changing App_Url
Just upload your Laravel files to /public_html/subdomain/
Then create a new file called .htaccess (yes, in the same subdomain folder) and then insert this code so it would start loading index.php from /public_html/subdomain/public/ folder which exists in Laravel App:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Save it. When you visit your subdomain URL now, the app should work.
If it throws any errors, then most likely your index.php paths aren't correct or you do not have vendor/ folder.
.htaccess is of course the best way. But if you don't know how to do that, I think you can create a subdomain from your hosting provider (like hostinger, etc), and after that, you can upload it to that folder (the one with the subdomain). Ask the hosting provider contact person, they will gladly help you to set up the subdomain
Good Day!
Hello,
Currently I was working on laravel and im new on it. I keep looking a solutions on my problem and i couldn’t find a solution on this. My laravel work is accessible already without /public in the url I fix this thru .htaccess, but it can be access also with /public in the url. Please see links below for your reference.
https://utok.ph/
https://utok.ph/public
my htaccess file
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
.htaccess files wont work on this, what i did is i update the root directory in my server side.
instead the root will be at public_html I change it to public_html/public
When migrating an old project to a new, Laravel based project, we would need to redirect (301 Header) old routes to new routes, e.g.
/index.php?page=shop ==> /shop
/index.php?category=abc&product_id=123 ==> /abc/item-123
For this, we've prepared a proper .htaccess file that works perfectly on the old project. However when we deploy the new project and change the domain DNS, the htaccess also needs to be in the new folder.
In Laravel, we do have /public/.htaccess, however, adding our .htaccess pieces won't work together with Laravel Forge. It is a simple .htaccess file that looks like:
<IfModule mod_rewrite.c>
# Enable Rewrite Engine
RewriteEngine On
RewriteBase /
# index.php?page=user&sub_page=settings
RewriteCond %{QUERY_STRING} ^page=user&sub_page=settings$
RewriteRule ^index\.php$ /users/notifications/permissions/edit [R=301,NC,L,QSD]
(... and so on)
</IfModule>
So now we are wondering: how can we make it work, that it will forward old routes to the new routes in the same project based on Laravel?
Laravel Forge uses an nginx.conf file (which you can configure in forge) instead of the .htaccess file.
You can use the nginx reference to re-create your settings: https://nginx.org/en/docs/. You should look at the sections: location and redirect.
Hope This Helps!
I'm new in Laravel. I want to create a laravel project but I don't know how to upload the project in my web hosting, Do I need a VPS? or with my web hosting can shared on internet?
VPS is more expensive than Web hosting, and I just have web hosting and obviously I want to upload it there.
It's pretty easy.
You basically need to split your project files into two different folders before uploading.
Steps to take:
All laravel project files inside your public folder should be moved to your public_html folder on your server.
On your server, create a new folder e.g my_app on the same directory level as public_html and move the rest of your laravel project to that.
Go to your public_html/index.php and edit the require and require_once lines to match your directory structure.
In your case, that would be:
From __DIR__.'/../bootstrap/autoload.php'; to __DIR__.'/../my_app/bootstrap/autoload.php';
The easiest way is to keep the structure as it is and upload a .htaccess file at the root.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
on my case for laravel 6 its working parfectly!
I have the front end fully working in a codeIgniter application. Now, I have to create admin as well. So, How would I create the admin section creating a new directory. Without interrupting codeigniter directory structure.
localhost/myapp/admin
CodeIgniter already supports 1 subfolder level within the controllers folder. So within /applications/controllers/ you can just add /applications/controllers/admin/ and it will work fine.
you could omit it out via .htaccess so that the directory actually works like a directory rather than how its initially developed to work.
RewriteEngine on
RewriteCond $1 !^(index\.php|admin|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
what this does is turn on apache modrewrite then tells apache any calls to index.php, robots.txt or yourdomain.com/admin/ (and any sub-folders/files within) treat as you would normally without codeigniter mucking up the works. Also this will remove the required index.php from the URL you will be able to link to your site like
mydomain.com/home/
instead of mydomain.com/index.php/home/
There's an explanation about that in CI User Guide: Managing your Applications