Laravel Apache DirectoryIndex now needs index.php - laravel

We have an app that we upgraded from 5.x to 7.x. After a fair amount of edits (really not bad) we have the 7.x version running.
But to get the app's root URL to work we had to add index.php to the DirectoryIndex setting. Without this we got permission denied error (as access to directory not allowed).
paths beneath the url seem to work (ignoring css issues, etc), so we assume the rewrite was working.
Why the change? Doesn't seem like the migration should have changed this.

Never mind. I see that the original .htaccess file had DirectoryIndex set. Not sure if this was a laravel change or something we added.

Related

htaccess problems ("/file/" serves file.php)

I was starting to implement mod_rewrite rules on my site when I came across some weird behaviour. I removed my htaccess file for this test, to take it out of the equation.
My local dev site is at http://dev.mydomain.com and is a virtual host.
If I go to, eg "http://dev.mydomain.com/blog/", that folder doesn't exist, but apache finds a matching php file "blog.php" and instead displays that.
This only happens when there is a matching php file - when there isn't, eg "http://dev.mydomain.com/barfblurg/" I just get a 404.
It's like there are some extra mod_rewrites going on above where the site htaccess would be - that when /file/ couldn't be resolved, it searches for other matching files and instead serves this - but there are no other htaccess files that would have an effect, so this must presumably be a config thing? I can't see anything in the apache.conf or php.ini that would cause this behaviour.
(This also doesn't happen on my live host elsewhere, so it's definitely a config thing.)
Anyone point me to where to turn that behaviour off, because it's interfering with the url rewrites I want to do?
(Apache2, OSX, 10.10.5)
This behavior is due to enabling of option MultiViews.
Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and makes Apache server match extensions of files. So /file can be in URL but it will serve /file.php.
To turn this off use:
Options -MultiViews
at top of your .htaccess or in Apache config/vhost file.

What kind of server configuration is needed to have a laravel app working

Using cpanel I have upload into a server a laravel application. During the development I have used MAMP and it works fine.
When I upload the application into my host server, I only can see the first page:
http://myurl.com/appname/public/
When I try to navigate I always get this error:
Not Found
The requested URL /myurl.com/appname/public/account/sign-in was not found on this server.
What is the problem? Are there any special configuration for laravel applications?
Edit:
.htaccess file content:
Options -Indexes
SetEnv DEFAULT_PHP_VERSION 55
I tried to add RewriteBase /like this:
Options -Indexes
SetEnv DEFAULT_PHP_VERSION 55
RewriteBase /
But it didn't work either.
I'm using this host https://www.ecowebhosting.co.uk/?page=webhosting&tab=advanced
You didn't mention which web server you're using, but if it's apache, it looks like you need to either
Tell Apache to process .htaccess files (so it can see the rewrite rules that pass everything to index.php
Turn on the mod_rewrite module, which is the module that does the work of rewriting URLs
When you request a URL like
http://example.com/appname/public/account/sign-in
in a Laravel application, the rewrite rules turn that in
http://example.com/appname/public/index.php/account/sign-in
Behind the scenes. It looks like your server isn't setup to do this. Also, since you're serving Laravel out of a non root folder, you may need to set the RewriteBase. However, generally speaking, the ideal Laravel setup is one where the public folder is your web root. If possible, I'd configure your server so that's true as well.

Wrong redirection to old site after Magento's duplication

I’ve got this problem: Magento redirection problem after moving
I changed local xml, deleted cache, changed secure and unsecure link, everything… It doesnt’ work. The only difference is that I duplicated my installation on the same server and I changed subdirectory’s name for the second installation. But I tried also on another server and is almost the same, except for the fact that it keeps linking me back to Google, and not to old domain.
I noticed that if, on the other server, I don’t change subdirectory’s name everything works (and I don’t understand why) but I want on the same server 2 identical installation with 2 identical databases. How can I? What’s the problem? How can I avoid this wrong redirect?
Magento relies heavily on caching. I've noticed in the past I've had to clear my browser internet cache before the redirects updated.
Also if you cloned/duplicated the code & database, its likely you will have the old URL's in the rewrite module. Have you tried reloading all the indexes after moving and changing the URL's in the magento configuration?
Worst case you may have to change the URL in the core_config_data table in the database.
There is no reindex required for base_url to be taken in account.
Only cleaning cache is required. Are you sure you did it well ?
What cache system are you using ?
What did you changed in your local.xml for this ?
Are you sure you didn't left old information in a local.bak.xml for example ? Magento reads every xml file in /app/etc
I have encountered this when moving, and it ended up being that my .htaccess file still had an old rewrite rule pointing to the old domain. In case someone else has this issue for which the other suggestions to not apply, look for something like this:
RewriteCond %{HTTP_HOST} !^www\.localhost\.com$ [NC]
RewriteRule ^(.*)$ http://www.localhost.com/$1 [R=301,L]
and make sure obviously that the localhost.com matches your domain (the above simply redirects with a 301 permanent redirect rewrite any request that does not begin with www.localhost.com to http://www.localhost.com/ (such as the non-www localhost.com)

Magento installation Problem in plesk

I have installed magento from Plesk,The home is well,with layout buy when I click any link it show "Not Found" message.
I can not figure out the problem
Thanks in advance.
It looks like you have a problem with Apache mod_rewrite.
Anyway, you can check is it true. Let's just say that you where going to open http://www.example.com/electronics and got 404. Ok, no panic. Try to edit URL to be like this: http://www.example.com/index.php/electronics
If it works, than definitely you have a troubles with one of the following:
Apache mod_rewrite is not enabled. If you can open a page with phpinfo(), you may try to search "mod_rewrite" on that page. No results found -- no mod_rewrite... Call your hosting support.
You need to set RewriteBase directive in your .htaccess file (it may be hidden for web based filemanager). By default the line with RewriteBase is commented, and you can uncomment it and leave it's default value "/" if your Magento is uploaded to document root. If your Magento is in some sub-directory under document root, you need to set RewriteBase value lie this "/my_folder_with_magento".

Product images not showing after migration of magento website

I recently migrated my magento website to a different server, and here's the process I used:
made a dump of the database.
copied all the system files from the FTP to my hard drive.
emptied the VAR folder
emptied the media cache folders
replaced the strings in the SQL dump from http://www.oldsite.com to http://www.newsite.com
restored the database on the new server
modified the local.xml file to suit the new database host, login and password.
uploaded the system files to the new server
Everything seems to work fine, except for the fact that the product images are not being displayed on the frontend for some reason.
For example, here's a path from an image that was supposed to be showing, which I got through firebug:
http://www.newsite.com/media/catalog/product/cache/1/small_image/113x113/9df78eab33525d08d6e5fb8d27136e95/1/_/1_9.jpg
When I search for the path of the image the site is supposed to show in the FTP, the file is actually there. I can download it and display it on my computer. I don't know why this is happening. It doesn't make any sense to me.
This /media/catalog/product/cache/ was generated by the system, because I erased it myself before uploading the site, so I guess it isn't a cache related issue.
Well, I described the issue the best I could. I hope you can help me out.
EDIT:
Hmm, it turns out the problem was the .htaccess file inside the media folder! Removed the file -> Problem solved!
Just in case anyone else has the same problem, removing the .htaccess in the media folder did the trick. I don't know if that's the best possible solution though! Thanks!
Change Options All -Indexes to Options -Indexes in the above mentioned .htaccess file.
copied all the system files from the FTP to my hard drive.
This one makes me a bit suspecting. Magento has case-sensitive folders in the media folder. There would be, for instance, an 'a' folder and an 'A' folder in the same location.
If you downloaded your files unarchived (file by file) via FTP to a Windows machine, this would cause a conflict and would omit up to half your images.
Ok, since everything checked out with the base URL, my next suggestion is a migration path option if you have cPanel on the old server, and since most do, this should help:
Create a full backup of the account using cPanel. This will create a tar.gz of the entire account.
Download the tarred backup to your computer and unzip.
Find home_dir.tar - this is what contains your HTML root information. You can either upload this directly to the server and untar there using SSH, or do it on your local computer and upload.
Find the SQL folder in the untarred backup. There should be a dump of your database there. Use source to put that information into a new database.
On the server, delete use_cache.ser and change config information for the new database.
Your .htaccess should have come over in the home_dir.tar, but make sure that it's correct per our other question
Once that's done, you should be fully functional, unless you need to make changes in the database base_url for the new server.
Images not showing in Magento 1.7 to 1.9 upgrade:
My solution:
in /media/.htaccess
fixed options syntax:
# Options ExecCGI Includes IncludesNOEXEC SymLinksIfOwnerMatch -Indexes
Options +ExecCGI +Includes +IncludesNOEXEC +SymLinksIfOwnerMatch -Indexes
removed these. Maybe conflict with .htaccess in site root directory??
# For security reasons, Option followsymlinks cannot be overridden.
# Options +FollowSymLinks
# Options +SymLinksIfOwnerMatch
# RewriteEngie on
also changed ownership of .htaccess to apache
chown apache:apache /var/www/mystore/media/.htaccess
Would like opinion of why these may be causing 500 errors.
php bin/magento catalog:images:resize
This helped me, but it take's a lot of time to complete
for magento 2.4.5
in pub//media/.htaccess
change „FollowSymLinks“ to „SymLinksIfOwnerMatch“. example:
############################################
enable rewrites
Options +SymLinksIfOwnerMatch
RewriteEngine on
## you can put here your pub/media folder path relative to web root
#RewriteBase /magento/pub/media/
############################################

Resources