I have freeBSD installed on IBM server. There is also apache, php and mysql installed on the server. A PHP application running on this machine is working just fine, but our new version of the same application developed in Codeigniter gives a "Page Not Found" error.
The thing is the application is accessible and runs well (only the non-english character are displayed not well) if the index.php is included in the url.
I have modified the file .htaccess to remove the index.php from the url, I kind of need to use the .htaccess in the application's root directory. This (using .htaccess) is actually causing the error.
Please let me know what configuration do I need to do.
Edit:
Bellow is the content of .htaccess in the root directory of the application:
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ /football/index.php/$1 [L]
Related
My goal is to get index.php as my default document working, but I get the error "The page cannot be displayed because an internal server error has occurred."
At first I thought it could be the configuration path mapping, which I have set the virtual path / to map to \site\public with type Application.
However, when I put a test file index.html in my public folder with a simple <p> hello world</p>, running the app worked fine.
Why wouldn't the equivalent index.php work?
If you haven't done this already so, set the default document (index.php) your WebApps>> Under Application Setting blade on the Azure Portal.
“Default document and map the path “Virtual applications and directories”.
On Linux, the container runs Apache, you can rewrite the URL to public/index.php with a single .htaccess file in our root directory.
Also, ensure that Rewrite rules are appropriate to map URLs to public/index.php file.
Furthermore, the default PHP image for App Service uses Apache, and it doesn't let you customize the site root for your app. To work around this limitation, add an .htaccess file to your repository root with the following content:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^.*$ /public/$1 [NC,L,QSA]
The document -If you would rather not use .htaccess rewrite, you can deploy your Laravel application with a custom Docker image instead.
I have recently deployed a Laravel project to my live web server via FTP (Filezilla). Inside my young1.org web root folder I have the subdomain folder bookings, which displays web content at http://bookings.young1.org. Inside that folder I have the folder, 'laravel' that contains my entire laravel application, and inside that folder there is a 'public' directory.
I have imported my local database to one of the database accounts on the live web server via phpmyadmin, and I have switched the 'DB' credentials to point to the new database inside the env file in the laravel project root (changing the following variables: DB_DATABASE, DB_USERNAME, DB_PASSWORD).
When I navigate to http://bookings.young1.org/laravel/public, the home page of my application appears, fine and dandy. However, when I click on any of the internal links (e.g. the login and register) buttons, I just get a series of blank pages, and none of the internal pages appear.
Would anyone be able to take a guess at what the problem might be?
I have tried altering the .htaccess file to look like the below, and changing my 'PATHS' variable inside public/index.php.
Thanks,
Robert
London, UK
// public/.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
// public/index.php
require DIR.'/../laravel/bootstrap/autoload.php';
$app = require_once DIR.'/../laravel/bootstrap/app.php';
do you have SSH on the server? if yes did u install laravel as you're supposed to, also could you include the .env file contents, you can mask out the DB username and pass and the key you had to generate
never mind my mistake, i clicked on a link and got a SQL connection error (refused)
i still need to know if you installed laravel via SSH or that you just made the public folder the root, because if that's the case laravel cant help you with that (you need a VPS and not a webhost that only supports FTP as far as i know)
and to be sure
BE CAREFULL!!!
you have SQL connection errors that show credentials
Notice that your URLs work fine if you use index.php in them, i.e.:
http://bookings.young1.org/laravel/public/index.php/register
To allow URLs without index.php the mod_rewrite module on your Apache web server must be enabled.
First try to add this line in your .htaccess file of Laravel above RewriteEngine On:
Options +FollowSymLinks
This directive is needed to enable mod_rewrite in .htaccess context.
If it doesn't work after this, then you can check if module is enabled on your web server, the easiest maybe is to paste this in the beginning of index.php in public folder:
phpinfo();
Then open any page and search for mod_rewrite on the page, and see if you can find it under Loaded Modules. If not, you have to enable it.
To do that, if you can access through SSH you can do:
sudo a2enmod rewrite
sudo service apache2 restart
For more help on enabling mod_rewrite on Apache web server, check this answer.
I'm having an annoying problem, i've developed a MVC php application, which of course uses a lot of redirects by controllers to controllers and so on.
Well, here's the issue.
On my MACs (note that i'm using a plural) works fine. Different versions of OSX, same version of MAMP on each one, same configuration of MAMP on each one. Even on the macBook Pro of the my office colleague it works fine with MAMP.
But when i move my application on a ubuntu server it causes a REDIRECT LOOP
between the login controller and the home.
After various experiments i think that the problem is the different configuration from MAMP to UBUNTU.
On MAMP i'm using the php 5.6.10 Version, enabled mod Rewrite (i use .htaccess to rewrite the url). Well, i would like to try to move my MAMP config to the ubuntu server. But i don't know how.
In MAMP i have 2 possible directories where the php.ini is located.
1) bin/php/php5.6.10/conf/php.ini
2) conf/php5.6.10/php.ini
Both of them are edited at the same way. I also think that the problem is inside the Apache2 config and not inside the PHP config, but i'm not 100% sure.
Keep in mind that i'm not very familiar with the htaccess files, so the rules inside my htaccess comes from a codecourse tutorial. But however on MAC it works...
However, here's the .haccess file that handles the URL rewrite:
Options -MultiViews
RewriteEngine On
RewriteBase /astrid/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
AddType 'text/css; charset=UTF-8' css
Also if you want to take a look to the project code here's the git repository:
Astrid
I'm stuck and i don't know how to figure this out! D: Any kind of help is extremely appreciated! Thank ya'll!
I am learning to code in PHP and mysql and need to be able to run PHP files using a wampserver. I have correctly installed wamp and have it online through Windows 8, however when I go to run my PHP file I am always given Error 404. I have ensured that my Slim file and .php file are in the correct directory and I have also modified the .htaccess accordingly so that it reroutes to the proper file if a URL is not found since I am testing this on my local machine. Here is a some of my sample code:
require 'C:\wamp\www\easysites\codeguy-Slim-b8181de\Slim\Slim.php';
\Slim\Slim::registerAutoloader();
$api = new \Slim\Slim();
$api->run();
I have traced the error to $api->run() and was getting an error from the call stack at one point that indicated an error had happened in Slim's environment.php at line 123 where the URL is first dealt with. If I run the basic index.php file generated by Netbeans, I get the usual text that alerts me that it is working, however try to run the php file using Slim it errors out which are in the same sub directory under root. Slim is correctly loaded by the php file, but will not allow me to run anything else thus preventing me from seeing the database that I have imported.
Does anyone have an idea of what could be going wrong? I have a co-worker who has successfully run the file but we are unable to make it run on my machine using the same types of changes.
The .htaccess file is as follows:
RewriteEngine ON
RewriteRule ^API(.*)$ /API/api.php [QSA, L]
The file I am trying to run is in a folder contained in the root directory named API, and the file I am trying to run is api.php.
When I followed all the instructions of the installation of slim exactly (installing it on easyphp on my local windows machine), I got the error 404.
I changed the .htaccess to the following, and then it worked fine:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ %{ENV:BASE}index.php [QSA,L]
I have 3 servers, a localhost apache server, a testing remote server and the production live server.
I have the same installation of codeigniter and site set-up on all 3 of them and on the localhost and testing servers routing without 'index.php' works 100%. On the Production server however, no matter what the URL says only the homepage (via the default controller) will be shown, it seems all routing rules are being ignored except the default one.
If however index.php is added in the URL then it will work like it supposed to.
For instance if the URL on the production site is: 'www.mysite.com/information' then the content that loads is form the default controller.
But when the URL on the production site is: 'www.mysite.com/index.php/information' then the content that loads is from the 'information' controller.
This is the contents of my htacess file: http://pastebin.com/cDaZVJ8A
This is my routes config file: http://pastebin.com/7Ewc2bwN
My $config['index_page'] is set to nothing.
I really dont know why its not working, the same setup on all servers in term of codeigniter itself, and mod_rewrite IS working on the production server.
I don't know what to do, how can I find-out what's wrong?
This is quite a common problem that often occurs when people move a codeigniter install from one environment to another. I have no idea why it occurs, could be a difference in server OS or apache settings, but the solution is often to add a question mark ? to the RewriteRule for the index.php in your .htaccess file.
Old:
RewriteRule ^(.*)$ index.php/$1 [L]
New:
RewriteRule ^(.*)$ index.php?/$1 [L]
Check your Apache virtual host configuration and verify that you have AllowOverride All in your directory definition.
Maybe something is wrong with your .htaccess file?
Once I had problem when I moved application to production server, because RewriteBase was set to some directory on development server.
On my production server application was in web root directory, so RewriteBase should be /, and i had /something there.
Once i had silly problem with upper/lowercases, when i moved site from development server (windows) to production (linux).
I had the same problem. I was using function to convert article names to URL's (slugify).
On localhost and on server this function returned slightly different urls.