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

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.

Related

Laravel Ngrok and absolute URLs

I used this command to startup ngrok for a laravel site, namely testsite.local:
ngrok http -host-header=rewrite testsite.local:80
I have testsite.local defined in /etc/hosts to map to 127.0.0.1
This works, Ngrok starts up just fine and now serves the local site on some random *.ngrok.io address, which I can access. But all URLs within the laravel application (e.g. internal links, or urls for loading a css or js file) are absolute urls to my locally defined domain, like http://testsite.local/news, or http://testsite.local/css/styles.css. In other words, I can load the site fine, but anyone else just sees a bunch of unstyled html and gets a non functional site.
This has to be a general issue for anyone who uses ngrok and has absolute URLs within their project, but google didn't yield anything useful.
Two possible approaches come to my mind:
rewrite all links in the application to be relative instead of
absolute (oh god please no)
any client that wants to access my site via the *.ngrok.io url has to map the 'testsite.local' domain within their very own /etc/hosts file to the ngrok.io url.
The approaches may work, but this seems so far stretched... isn't there anything else one can do?
SOLUTION
https://stackoverflow.com/a/54488972/718980
You need to use Apache Module mod_substitute.
First, enable module:
a2enmod substitute
service apache2 restart
Then, add the following to the .htaccess file:
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s|<your-local-link>|<your-ngrok-link>|in"
More information: https://httpd.apache.org/docs/2.4/mod/mod_substitute.html
In xammp/apache/conf/httd.conf
DocumentRoot "C:/xampp/htdocs/{your-project-path}"
Directory "C:/xampp/htdocs/{your-project-path}"
In the httpd.conf set your DocumentRoot and Directory to the path of your project.
DocumentRoot "C:/xampp/htdocs/projectName"
<Directory "C:/xampp/htdocs/projectName">

How do I configure Laravel to properly work on localhost?

So I have this website, that some else build on Laravel. Since I need to make some changes I want to copy this website locally and make it work locally, so that later on I can apply the changes. I really don't want to work on the live site.
So I copied the whole website in my local folder but in order for me to see each page I have to follow this link:
http://localhost/XXXproject/html/index.php/auth/signin
I would like to know, where can I fix this. I want to remove the index.php from the url and be able to see the images without getting 500 errors everywhere. Something more like this:
http://localhost/XXXproject/html/auth/signin
And this is my htaccess.
RewriteCond %{REQUEST_URI} !^/html
RewriteRule ^(/?)(.*) /html/$2
During development I would recommend using Laravel's little HTTP server which will host the site without any external web server software such as Apache, where configuration might be an issue.
You can do this by going into the root directory of the project and typing:
php artisan serv
However if you do want to use a webserver for local development purposes with Laravel 4, you'll need to configure the rewrite rules appropriately. Although it does seem the rewriting is working to some extent, you may need to configure your webserver to consider index.php as a root document. Can't really help you more than that without more information on your webserver software and its current configuration.
Finally I solved it, I went through the installation and configuration steps from the website, and realize that I was working with a htaccess that was under wamp\www folder, I even tried making one for wamp\www\xxxproject.
But when following the steps I realized there is a htaccess inside the public folder from the project, I changed that one with the one from the website and now it works!

Magento Use Web Server Rewrites in Multi Domain Setup

I have to two stores each having different domain. They are hosted on dedicated server with SuExec disabled. I have copied the .htaccess and index.php and everything works fine.
The problem I am having is with my 2nd store Web Server Rewrites. As soon I enabled this for the 2nd store which is using symbolic link to the root directory, it starts giving page not found error.
domain2.com/index.php/abc.html ----- Works Fine with Use Web Server Rewrites Turned Off
domain2.com/abc.html ----- Does not work with Use Web Server Rewrites Turned ON
The base store works without any problem.
Any help is much appreciated.
Farrukh Khan
-> Flush The Magento Cache
Goto System->Cache Management
Refresh the catalog rewrites
Goto All Cache and change drop down to Refresh.
Click save
On most server, this should take out the index.php in your URL’s.
If you are getting a 404 error, continue reading.
-> Fixed Mode_Rewrite Errors
Please check you webserver configuration.
Do you use Apache? Maybe there is something like "AllowOverride none" in your configuration which disables .htaccess-files (the .htaccess-file in your magento-root-directory defines the rewrite-rules).
The most common cause for this is that you have an incorrect .htaccess file in your ftp.
Goto the magentocommerce.com site and download the magento files again.
Extract the files, and ONLY upload the .htaccess file to your Magento root directory.
This should fix any problems related to enabling the use of web server rewrites in Magento.
I was facing the same problem above, but now i solved already. The main reason for that problem is .htaccess file. By replacing .htaccess file with magento default .htaccess file solve all the problem. Web Server Rewrites Turned on or off, you can do as you like.
After saving the configuration, don't forget to clear cache.

Joomla SEO doesn't work after migration

I have a Joomla 1.5 website and I enabled SEO on it. I moved it to different location with different DNS and now SEO doesn't work. How can I fix it?
Three checkboxes ("Search Engine Friendly URLs", "Use Apache mod_rewrite" and "Add suffix to URLs") on global configuration page regarding SEO are checked.
Is the new server definitely an apache web server?
Is mod_rewrite enabled on the server?
If the answer to either of the above is no, then you have problems. For the first you'll need to change servers. For the second you'll need to get the server administrators to enable (and possibly install) mod_rewrite.
Is your website in a sub-folder? For example /joomla/ for example.
If so you need to edit the RewriteBase line within the .htaccess file.
Change the line from
RewriteBase /
to
RewriteBase /joomla/
Rename your htaccess to .htaccess.
There might be more problems, but I think you should start checking this:
1) You have the right .htaccess file in your joomla root and it is readable by your Apache user.
2) Go to the administrator > Site > Global Configuration and check you have "Search Engine Friendly URL's" and "Use Apache mod_rewrite" to "Yes".
3) Make sure that the Apache you are using has all the modules needed.

Custom URL's to users, dynamically at a scale

I need to create custom urls for my users, for ex: www.example.com/alpha, www.example.com/beta. I was creating symlinked directories, which I think worked as a good starting point for prototyping. However, now I need to do this at a scale, running on several web servers behind a load balancer. I am not sure on the right way to do this.
If you are running on an Apache server and you have access to .htaccess files then try this in a .htaccess file
RewriteEngine On
RewriteRule ^(.*)\.html$ index.php?p=$1
This will point all URL's to index.php?p=* internally.
A user will see the .html, and the server interprets it as the pointed url.
Example: yourdomain.com/cocacola.html -> yourdomain.com/index.php?p=cocacola

Resources