I have a Cake 2.3.8 app that works fine on localhost and I uploaded it to an Ubuntu 12.04 EC2 instance, but on the index/home file I'm getting a "Missing Controller" error.
The CSS, header and footer load fine on the home/index page, but it can't seem to find the controller. Every single other page/controller of my app won't even load, I get a 404 error.
I tried this but my issue still persists.
What else should I look for that would cause it to not find the controller and not even load any other pages?
Update
I moved my contents to /var/www so it would be accessed through my-ec2-instance.com. When I go to my-ec2-instance.com/index.php the page displays (which is PagesController/home.ctp). However, anything else gives a 404 error. Modrewrite is also enabled
I can also access my actions when I reference index.php, although it displays in mobile format for whatever reason (I have a responsive template). Ex: www.my-ec2-instance.com/index.php/users/login works, although it's in a mobile format
www.my-ec2-instance.com/index.php //works
www.my-ec2-instance.com/index.php/users/login //works, but mobile format
www.my-ec2-instance.com/users/login //404 error
Please connect your instance via putty then press
sudo nano /etc/httpd/conf/httpd.conf
Check the given below line and remove the # tag
LoadModule rewrite_module modules/mod_rewrite.so
After that you can replace:
AllowOverride None
with
AllowOverride All
Note: AllowOverride None -> AllowOverride All.
From Crtl+X then press Y then press Enter (you can use this command according to your OS)
After that you can execute the command in putty
sudo service httpd restart
Then check your .htaccess file (please make sure your .htaccess should be correct) for cakePHP .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Sounds like an issue with your .htaccess file which is what would properly rewrite short URLs & handling controller routing.
Related
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.
Update I have re- done the code and folder system of my mod re write on localhost still nothing
the link only shows like this
http://localhost/cms/member/profile.php?member=10308
my entire .htaccess file
RewriteEngine On
RewriteRule ^cms/member/([^/]*)$ /cms/member/profile.php?member=$1 [L]
when i click on the link it does nothing. if i change in the browser to
http://localhost/cms/member/10308
it says page cannot be found.
Update the problem was this peice of code causing it to not display right
<?php
if(empty($_GET['member']) || $_GET['member'] <1000 ) {
redirect(ROOT_URI);
exit;
}
?>
But i need this code.
the url will work but i need to type it in manually it wont automatically change the url
As you are using an .htaccess file which is placed under the directory "cms", you should use the following directives:
RewriteEngine On
RewriteRule ^member/([^/][0-9]*)$ member/profile.php?member=$1
This will send the request http://localhost/cms/member/(any-number) to http://localhost/cms/member/profile.php?member=(any-number)
Note:
mod_rewrite should be enabled.
In httpd.conf (or apache2.conf), replace AllowOverride None by AllowOverride All to enable .htaccess
Restart Apache server.
I have a QNAP NAS with Apache correctly installed. Some pages are linking fine except for ones using any RewriteRule. All other pages are linking correctly to mysql and displaying fine its the ones with any RewriteRule, these are showing up as a 404 error like this:
The requested URL /share/CACHEDEV1_DATA/Web/clients/hembury4x4/couk/view-sitemap.php was not found on this server.
URL = http://192.168.1.210/Web/clients/clientname/sitemap.html
FILE= http://192.168.1.210/Web/clients/clientname/view-sitemap.php
My rule is quite simply: RewriteRule ^sitemap.html$ view-sitemap.php [NC,L]
I have copied all the site files from my computer where the redirect was working perfectly. What do i need to add on my htaccess file?
Thanks in advance
First, apache should have rewrite module. It should present in the output of httpd -M command.
Then you should allow .htaccess files. This can be made by adding AccessFileName .htaccess directive (if it's absent) to your httpd.conf file. Also check you have this section:
<Directory />
AllowOverride All
</Directory>
I have Apache installed.
I have LoadModule rewrite_module modules/mod_rewrite.so un-commented and set every instance of AllowOverride None to AllowOverride All in http.conf.
My site is in a subfolder, so its like http://123.34.56.123/Website/ to get to it.
.htaccess file
RewriteEngine On
RewriteBase /Website/
Options +FollowSymLinks
RewriteRule ^index.php http://www.google.com/? [R=301,L]
But when I visit the above address, it does not redirect to google.com and, instead, shows the contents of index.php.
Update:
Added junk to the .htaccess file and http.conf to force a internal server error, and it still just goes to my index.php.
Did a var dump on $_SERVER, and found this out: ["SERVER_SOFTWARE"]=> string(17) "Microsoft-IIS/6.0", but can't find any program files around IIS.
Based on your question, some probable causes of your problem:
Incorrectly named .htaccess file. You call it an "htaccess file" repeatedly in your post. The filename must be .htaccess (with the leading .).
File in the wrong directory. Make sure this file is in the root directory of your site.
The module you need to enable isn't mod_userdir.so, but mod_rewrite.so. Look for a line like this one: LoadModule rewrite_module modules/mod_rewrite.so
Make sure the [R=301,L] is on the same line as the RewriteRule to which it applies, or you will have errors.
Also, don't do a 301 on this, even for testing -- it will permanently redirect traffic to your index.php to Google. That's what a 301 does. For testing, use a 302.
Converting comment to an answer, if your update to httpd.conf mysteriously fail to change anything on Windows, edit httpd.conf as Administrator (not a member of the administrator group, Administrator) to avoid Windows silently doing "data redirection" of httpd.conf edited out of Program Files.
http://blogs.windows.com/windows/archive/b/developers/archive/2009/08/04/user-account-control-data-redirection.aspx
I've had to move from testing on the live server, to testing locally on a virtual apache server. I've installed XAMPP just fine, downloaded and installed the wordpress files and the database. Everything looks great! The local version of my homepage is identical to the live version. There's only one problem: the homepage is the only page that works. When I click on one of the links i.e. the "about" page (http://localhost/wordpress/about/), I am redirected to the xampp control panel (http://localhost/xampp).
I have a good feeling this has to do with a problem with the "pretty links"/mod_rewrite rules. I made sure I brought over the .htaccess file, and it contains the rewrite instructions. The wordpress database has the proper permalink structure, and the httpd.conf file has the "RewriteEngine on" and the "FollowSymLinks" directives enabled. There has got to be some sort of rewrite problem here, although I am not ruling out something else stupid I might have done. Thanks for all your help!
-E
*Here is what the .htaccess looks like:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
In the httpd.conf, change the
DocumentRoot "/path/to/your/app/wordpress"
also
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/path/to/your/app/wordpress">
This should work, the path is absolute.
And do you have load the:
LoadModule rewrite_module modules/mod_rewrite.so
in httpd.conf??
If your server version works with a domain name, i.e: http://domainname.com is equivalent that http://localhost/wordpress the rewrite rules will be differents. post the rules here.
The problem is that wordpress does not believe in relative paths for some reason. There is an assumption that wordpress is running from the server root not a directory under the root (e.g. /var/www/wordpress will not work, but /var/www/ will).
The problem is with the .htaccess file they provide. It should re-write it to index.php and not /index.php. Change that line in your config and it will work.
What happens is that it tries to actually go to the default document root (in my case /var/www/index.php, which does not exist since I am using http://localhost/worpress which is an alias for ~/projects/worpress). You can check your error log and it will tell you where it is trying to look for the index.php file (which will return a 404 error).
I can go on a rant about how stupid it is that they do that and how bad the whole software design of wordpress is. But I will spare you that :).