Vanilla php files in subfolder with laravel - page not found error - php

I have a laravel app: https://laravel-app.com
I want to serve custom pages from a folder on the same domain https:laravel-app.com/player/player.php
I have set the .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /player/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /player/player.php [L]
</IfModule>
But when I try and navigate to that page by using this direct url: https:laravel-app.com/player/player.php
I get the laravel routing error: sorry, the page could not be found
Can someone explain how to get around this?

Anything you want accessible you can put in the public folder of your application, which should be the DocRoot/WebRoot. You won't need any special rewriting or rules as it will be an existing file so the server will serve it fine.

Related

Laravel 8.4 – Remove Public from URL

I am working on creating a website that converts text into speech. I am using the script from codecanyon which is Developed with PHP 7.4.x and Laravel 8.4.x . The issue I am facing is that I don't want to show /public URL as a permalink to access the website. Now, if I type mywebsite.com/pubic then the website is accessible otherwise if I write mywebsite.com then it only shows the files. I followed some of the previous queries posted on StackOverflow but got no results.
The topic I followed is Laravel 5 – Remove Public from URL
I tried even by renaming server.php , copying .htaccess and rewriting it. But those all resulted in a screen showing up errors or even blank.
My .htaccess file is;
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
To remove the /public from the URL you are not going to use the .htaccess file.
What you are going to do instead is set the /public folder as the serving directory for your Server.
If you use Apache, just go to your /etc/apache2/sites-available/000-default.conf file and change the DocumentRoot from {your base folder}/ (usually /var/www) to {your base folder}/public
The content of public folder should go to the public folder of your server (fe it's public_html on my server), and everything else should be stored in a different folder (fe laravel_mywebsite). Then you should go to public_html/index.php and change the folder paths based on where you put your Laravel app.
If you want to only use .htacces, you just need to rewrite all requests from /public to /
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L,R=301]

404 route redirect on Doc Manager

I have a Doc Manager library. I'm having problem with the url routes, The public (frontend) part are on httpdocs with all the stuff (css, js folder, index.php...), and the backend are just on a parent folder. All It's linked to a subdomain.
If I access it on: https://fondodocumental.fundacioncb.es/ it will give 404 error page with redirection on https://fondodocumental.fundacioncb.es/folder/0.
But if I access on https://fondodocumental.fundacioncb.es/index.php it redirect's to https://fondodocumental.fundacioncb.es/index.php/folder/0 and it works. How can I fix it?
My friend have the same system on his domain and work's when he write: http://archivo.maimona.org/, look how it redirect's.
Thanks.
Use .htaccess file for the magic
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Laravel - unable to find new page (404 error - not found)

I´m looking for solution for my laravel project problem (laravel version: 6.5.2). I found a lot of similar questions, but no solution.
So, I have created new laravel project and then i put it on my hosting.
My FTP structure is:
- www
- AutsokolaIS
In www folder, I copied content of Public folder and in the AutoskolaIS other folders and files (app, bootstrap, config, etc.)
Everything was good, until I tried to create a new page linked to welcome page.
Link is mydomain.com/page. After click on this link, I get 404 error page. When I directly open the URL mydomain.com/index.php/page everything works.
I know it´s problem with .htaccess file, but I´m not able to edit .htaccess file in correct form.
Can anyone please help me?
Thank you
By default the website will be load from public folder. If you want to remove public from your url,copy .htaccess file from public folder to root and replace the code with the following..
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/$1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php

pretty urls laravel 5.4

Hi I am facing issues with settng pretty urls withput public in url but it is not working for me.
I already tried
Laravel 5.2 Pretty URLs,
Laravel 5 - Remove public from URL
and more similar urls but nothing seems to work for me.
I am using wamp, windows 8
I have make sure mod_rewrite is on, and is working properly.
Here is my htaccess on root.
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
my htaccess in test inside public folder
<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>
I have also tried pasting the htacess from public folder on root folder and removed the one from public folder but it dint work
actually the error which occurs is that my routes file skips all the patterns say if I have something like Route::get('/api/login', 'api#login') then it does works with urls containing public but when I remove public from url all the patterns are skipped. and it shows 404
I made sure all the requests are reaching public/index.php and mysterious thing is that when I print
var_dump(Request::root());
in routes.php it for url with public it says http://localhost/folderName/subFolderName/public but for the urls without public it says http://localhost/ and I think this is the reason why my patterns in routes file are not working.
P.S. I have set the title pretty urls laravel 5.4 instead of laravel routes not working because I think it is .htaccess which I needs to configure properly to get this working.
I do not want to change the folder structure because I believe in that there is some reason for which it is like this and There should be some work around for this.
Regarding setting vhosts I wont be able to do this on server (For I do not have the rights) so there is no use of setting a vhost on local as a work around as in login run I have to solve this.
Try this in your public/.htaccess
RewriteRule ^ /public/index.php [L]
And the .htaccess in root
RewriteRule ^(.*)$ /public/$1 [L]

htaccess/Permalink issue with Wordpress

I'm facing an issue with Permalink for Wordpress site that I have hosted on ubuntu server. Whenever I save the permalink setting I receive an error to modify .htaccess file and update the setting as provided below,
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
I did this activity but the links are not working I'm receiving 404 error.
Before updating this file link the url's used to work with index.php/
This .htaccess file is placed in the folder where I have installed the folder.
Any input in this regard will be appreciable.
Thanks in advance.
If this .htaccess file is in the /wordpress directory, then move it to the above directory, and it should work.

Categories