Laravel app is not running in public_html folder - laravel

When i deployed my laravel application to public_html/demo folder. Its working well in this folder but when i moved all my codes to public_html/ folder am getting a blank page, Also am not getting any errors in log/laravel.log, What should i do and why this problem is occurring

After so much of research i found the problem.
The PHP was not loading.
By adding these lines in the .htaccess file it resolves my problem
DirectoryIndex index.php login.php index.html
RewriteEngine on
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php70” package as the default “PHP” programming language.
<IfModule mime_module>
AddType application/x-httpd-ea-php70 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

add .htaccess file in your public html and write this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ demo/public/$1 [L]
</IfModule>
you should change the root folder using .htaccess like that

Related

Unable to open subdirectory laravel installation

In my /public_html/ I have installed an WordPress site. Now I have installed an laravel application inside /public_html/app/.
Then in /public_html/app/.htaccess I have added:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
In /public_html/app/public/.htaccess I have added:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /app/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
</IfModule>
When I trying to open https://example.com/app/ I've got error 404. When I try to open directly https://example.com/app/public I've got half working site because it is searching for the css/images in https://example.com/.
What is need to be changed in the htaccesss in order to work.
The goal is to have a button on the main WP site and when I click it to load the laravel site.
RewriteBase /app/
You need to remove the RewriteBase directive. This ends up rewriting the request to /app/index.php, when it should be /app/public/index.php. The default is to rewrite to the current directory (the directory that contains the .htaccess file), so the RewriteBase directive is not required here.
(Or, you could set this "correctly" to RewriteBase /app/public - but that is not necessary and would then hardcode this installation to the /app directory.)
I've got half working site because it is searching for the css/images in https://example.com/
It depends on where your images are. If images are located at /app/public/assets/images/myimage.jpg then you should be referencing your images using a root-relative URL (starting with a slash), excluding the public directory, eg. href="/app/assets/images/myimage.jpg".
UPDATE:
is this means that I now have to manually edit all images, links, buttons, etc on the site in order to add /app/... in front of the assets?
Ordinarily, yes. In the same way you have presumably added /app/ before all your internal links to your pages. (?)
Logo for example - <img src="/assets/main/img/logo.png">
However, since you are using a root-relative URL and your Laravel assets are in a known location, then you could workaround this by implementing a rewrite in the root (WordPress) .htaccess file to rewrite your Laravel assets to the correct location (presumably /app/public/...).
However, this does mean that you cannot then have an /assets subdirectory in the root (without implementing additional filesystem checks), nor have a WordPress URL that starts /assets, since it will conflict and won't be accessible.
For example, at the top of the /.htaccess file, before any other WordPress directives you could do something like the following:
# Rewrite Laravel assets to the correct location
RewriteRule ^assets/.+ app/public/$0 [L]
# BEGIN WordPress
:
Where $0 is a backreference that contains the entire URL-path that is matched by the RewriteRule pattern.
Now, any request for /assets/<something> will be internally rewritten to /app/public/assets/<something>. /assets/ itself won't be rewritten.

Remove theme folder name from codeigniter URL

I have pages inside a folder named frontend/page and url shows like www.domain.com/frontend/page/home.
How do I change it to www.domain.com/home
Also the entry home is dynamic it could be about us or contact
My .htaccess file is
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php56” package as the default “PHP” programming language.
<IfModule mime_module>
AddType application/x-httpd-ea-php56 .php .php5 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|uploads|documentation|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
If you want to redirect any page to it's corresponding controller which is in frontend/page sub-directory, you could modify the routes like below :
$route['(:any)'] = "frontend/page/$1";

Removing index.php from URL laravel 5.4 when virtual hosts points to public folder

There are countless posts here and elsewhere requesting help in taking out the public/ and index.php from a fresh laravel install on a live server. So many in fact that I'm a little embarrassed to ask this. However, Given that there is more than one way to skin a cat, I feel that the many different solutions can sometimes conflict with each other and cause more headaches.
I have taken out the "public" in the url from a recently launched laravel site by pointing the virtualhost domainname.com.conf to the public folder.
This however causes the need to put index.php after the domain in all requests or else the page doesn't work correctly.
When I do put index.php into the urls manually, some of the images can't be loaded since they don't have this hardcoded.
Furthermore, if I point the virtual hosts addresses directly to public/index.php, the site works but after about 10 minutes it stops working and nothing on the site will load, css, js images. It all stops. I assume this has somemthing to do with laravel view caches but clearing them doens't change any thing.
At this point I'm at a loss. I've put +8 hours into this off the clock and am getting pretty desperate.
This is my htaccess folder in public(no htaccess in laravel root is needed?)
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
This is the same setup I've used for other domains & laravel live sites with success. For some reason the index.php simply won't go away using anyone's solutions.
Any help? Have I been staring at the same htaccess/virtualhost files for too long?
Seems like you don't have the DirectoryIndex properly set.
Check your configuration, in my case I got it on dir.conf file:
file: /etc/apache2/mods-available/dir.conf
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm

Rewrite subdomain url like bigcommerce.com

i have 2 folder a and b
I want to rewrite url as like subdomain style.
domain.com/a => a.domain.com => it will run folder a
domain.com/b => b.domain.com => it will run folder b
Thanks in advance
Assuming the folders a and b are at the root of your domain, try adding this to the .htaccess file in your web document root folder (often public_html or htdocs):
Options -Multiviews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([ab])\.domain\.com [NC]
RewriteRule ^ %1%{REQUEST_URI} [L]
This assumes that mod_rewrite is both installed and activated for .htaccess files.
If you are not sure, to check if mod_rewrite is even installed, look at the list of installed modules in the output of phpinfo();
By default, mod_rewrite is not enabled for .htaccess files. If you are managing your own server, open httpd.conf
and make sure that the webroot directory block contains one of these lines: AllowOverride FileInfo or AllowOverride All

htaccess *.php to *.html object not found error

I am trying to transform URLs from index.php to index.html, servicii.php to servicii.html and so on.
I wrote in my .htaccess file, which is in my site root the following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.php$ $1.html [R=permanent]
</IfModule>
?>
But when I follow "Prima pagina" (Home) or "Servicii" (the only 2 pages created on site) it gives me a 404 error
Also, I have the code
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /fetesti/
RewriteRule ^(.*)\.php$ $1.html [R=permanent]
</IfModule>
on my local machine, which is XAMPP based. It gives me Object not found 404, and on my Apache log:
file not found [...]/index.html;
I know the rewrite engine is working (I wrote gibberish and it gave me 505 internal server error and made other tests)
What am I doing wrong?
Try just remove [R] permanent redirect, and switch extensions in rule
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.html$ $1.php
</IfModule>

Resources