Laravel 5 & Vue components – Remove Public from URL - laravel

I have a Laravel 5 project with Vue components. The project works fine.
But I removed the "/public" from the path using this instruction: Remove /public from URL
And now vue components don't work. Which files do I need to modify to recover Vue components?

I answer myself.
I hope this doesnt affect my status. Please administrators let me know...
After modify I need changing .htaccess like this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]
In this way the static files components will not be ignored. Like this components work again

Let me share my experience.
Inside public folder, there is .htaccess file.
You can copy it into project directory.
And in vendor/laravel/src/Illuminate/Foundation/Helpers.php, change asset file like this.
function asset($path, $secure = null)
{
return app('url')->asset("public/".$path, $secure);
}
It is some bad of touching src file, but it is working well always.
Hope it would help you.

Related

Laravel pagination broke on GoDaddy Production server

I have just uploaded my laravel application to my godaddy server and everything works apart from my 'search' functionality and 'pagination' which I presume are related to the same problem, being the URI. I thought maybe it is a .htaccess problem but if so I am unaware of how I can rectify this?
I tried deleting the config cache and it did not solve it.
.htaccess in public_html
<IfModule mod_rewrite.c>
RewriteEngine On
# Removes index.php from ExpressionEngine URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
.htaccess in laravel root
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
I am using 'variable->links()' to output the pagination links with 'paginate(11).
I hope somebody can be of any assistance which would be highly appreciated.
I adapted my research skills and managed to find a fix using the .htaccess found
https://stackoverflow.com/questions/22403519/laravel-4-pagination-not-working-links-are-ok-but-shows-all-results-in-each-page here.

Laravel serving up pages from invalid route

I have the following route: Route::resource('users', 'ProfileController'); When I go to site.com/users/123, it loads the page properly. I can also go to site.com/index.php/users/123 and get the same page (not sure if laravel is by default intended to do that).
If I change the url to site.com/does_not_exist/users/123, laravel returns a 404, as you would expect. However, if I go to site.com/does_not_exist/index.php/users/123, laravel loads the page. I can put any random path, non-existent path between site.com and index.php and it will work.
Why doesn't laravel return a 404 for this? How do I fix it so it does?
Because the index.php is the index.php in public folder that handles the incoming request and its a automatically generated class loader
This might work (similar question on how to fix this)
1-Renaming the server.php to index.php (no modifications)
2-Copy the .htaccess from public (like rimon.ekjon said below)
3-Changing .htaccess it a bit as follows for statics:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]
If there are any other static files needed just add the extension to the previous declared list
Source

CodeIgniter routes not taking effect

I just copied a codeigniter project from one folder to another in my XAMPP htdocs. These two projects contain exactly the same code, they're just in different directories.
In the copied project, the default_controller works fine but none of my routes work.
my routes:
$route['default_controller'] = 'home';
$route['404_override'] = '';
$route['dashboard'] = 'dashboard';
The index file is located at localhost/project/www
If I go to localhost/project/www/dashboard, I get a 404.
But if I do this:
$route['404_override'] = 'dashboard';
Then the dashboard controller loads correctly when I go to localhost/project/www/dashboard (or any other path, which would give a 404, of course)
The problem is not in the .htaccess file, since it's just generic:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Like I said, the code has just been copied from one directory to another. Any ideas as to what is preventing my routes from working properly? Have I missed something?
EDIT
After setting the 404_override and removing it again, the routes magically worked again. Everything is fine.
If anyone could shed a light on why this has happened, that might help the next guy who gets in this situation. But for me, the problem is resolved.
OK, the problem was that I had used uppercase for the name of the copied project, but was trying to access it with lowercase on a system that discerns between these two.
So, stupid
i think problem is you were using doing like this
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
instead you try it
RewriteEngine On
RewriteBase /www/
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Code igniter 404 page not found error

I have developed a web application on code igniter. This is the first time i am working on code-igniter After developing a web application on my localhost its working fine. But when I hosted the site in server the main index page was opening but the sub pages showing "404 page not found error". Can you please guide me.Here is my htacess file
RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*) index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+) index.php?/$1 [L]`
and in my routes.php I have added following line
$route['about'] = 'mycontroller/about';
Did you try setting the config ?
$config['base_url'] = "https://www.yoursite.com/";
There is a good tutorial on that at sajjad's blog
Copy the below code in your .htaccess file :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
my code had all class names starting with uppercase letter, however few posts mentioned changing the file name to match the class name. However, that didn't help. Finally the following helped:
create a file .htaccess and add the following lines of code in it:
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
it should work

Codeigniter Index file issue

I have already worked in the CI. But this time when i remove the index file. I am getting 404 error. But i did everything correctly. Here is the settings i have done.
.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|files\/images|files\/javascripts|files\/stylesheets|files\/swf|files\/upload)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /qrout/index.php/$1 [L]
Config File
$config['base_url'] = 'http://webscarlets.in/projects/';
$config['index_page'] = '';
I hope above settings are all correct. And i have tried added this 'qrout' folder in the base url still it's not working
Here is the website link
http://webscarlets.in/projects/qrout/welcome
Kindly guide me to solve this issue.
Thanks to all.
Try to use this condition .....ITs working for me
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
It looks like your rewrite condition is targeting js files and things like that. Those files don't need the index.php in their path. Only your Codeigniter files will.
I'd rework that conditional statement.

Resources