I am setting up an application on my ubuntu 18.04 localhost in a sub directory so the url looks like this: localhost/app-name.
The problem is that I keep getting an apache 404 error. I feel like I have tried everything between my default.conf and .htaccess. On the bright side if I type /index.php it atleast gives me a 404 page error from the site itself the site css. Here is my default.conf and .htaccess
FOr what it's worth it was written on litten framework
DocumentRoot /var/www/html/app-name/
<Directory /var/www/html>
AllowOverride All
</Directory>
<Directory /var/www/html/eduTrac-SIS/>
Options Indexes FollowSymLinks MultiViews
DirectoryIndex index.php
RewriteBase /app-name
AllowOverride All
Order allow,deny
allow from all
</Directory>
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /var/www/html/app-name/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
So I figure it out. I too out all of the extras from the default.conf and let the .htaccess do it's thing along with some other changes within the framework. It all worked out.
Related
I'm not sure what the problem is I followed the steps to remove index.php
Added to .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Selected Custom Structure
http://11.33.55.77/%pagename%/
Any page I visit is a 404 for example
http://url.com/faq = 404
The requested URL /faq was not found on this server.
Make sure the permalink of the faq page is actually /faq, if that's set up properly make sure mod_rewrite is enabled in your apache
Make sure mod_rewrite is enabled. sudo a2enmod rewrite.
This did not work for me
instead go to apache2/sites-available/default-000.conf
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
copy and paste the following configuration
I have a broken Cake PHP site that I did not write, but am charged with fixing. I have the main controller up, however no css/js/images, and when I click a link I get a 404 not found. I believe something is incorrect with mod_rewrite or the docroot config in apache.
While reading through Cake documentation, I came across this:
"app/webroot
In a production setup, this folder should serve as the document root for your application. Folders here also serve as holding places for CSS stylesheets, images, and JavaScript files."
In my /etc/apache2/sites-enabled/this-site, I see this:
DocumentRoot /u02/data/docroots/this_site
<Directory /u02/data/docroots/this_site>
Options -Indexes
AllowOverride none
Order deny,allow
Allow from all
</Directory>
So, my question:
does the above config block need to have:
/u02/data/docroots/this_site/app/webroot as the DocumentRoot and ?
Anywhere else you can think to look for troubleshooting this?
Since you have access to edit the apache config files - it's most appropriate to make a standard production install.
Fixing the docroot
does the above config block need to have: .../app/webroot as the DocumentRoot
Assuming that path exists: yes.
This will fix the broken css/js/images.
Fixing mod rewrite
Put the rewrite rules in the virtual host config:
DocumentRoot /u02/data/docroots/this_site/app/webroot
<Directory /u02/data/docroots/this_site/app/webroot>
Options -Indexes
AllowOverride none
Order deny,allow
Allow from all
// added
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</Directory>
This will then route requests for anything that's not a file to the application.
Verify that the rewrite rule used is compatible with the version of CakePHP in use, the above is based on the rule for the latest release - it changed over the years and using the wrong rewrite rule may have unexpected side effects.
What's actually broken
AllowOverride none
This prevents the .htaccess files from being read by apache. If you were to change this to AllowOverride all, and assuming the currently-ignored .htaccess files exist, the site would work - but as a development install.
Try this:
<VirtualHost *:80>
ServerAdmin xxxxxx#test.ro
ServerName test.ro
ServerAlias www.test.ro
DirectoryIndex index.php
DocumentRoot /u02/data/docroots/this_site
ErrorLog /u02/data/docroots/this_site/error.log
CustomLog /u02/data/docroots/this_site/access.log combined
<Directory "/u02/data/docroots/this_site">
Options -Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And you should have 3 .htaccess files:
/u02/data/docroots/this_site/app/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
/u02/data/docroots/this_site/app/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/u02/data/docroots/this_site/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Hope this helps ;)
Just getting started with Silex and having some issues.
Downloaded the fat zip file, unzipped it into wamp's www folder. So, here's C:\wamp\www\fat-silex\web\index.php:
<?php
require_once __DIR__.'/../vendor/autoload.php';
$app = new Silex\Application();
$app->get('/hello', function() {
return 'Hello!';
});
$app->run();
Problem is I'm getting Apache's 404's for http://localhost/fat-silex/web/hello, and also for any URL except localhost/fat-silex/web, where I'm getting Silex'es 404 (as expected). I guess the requests go directly to Apache, and are not routed by Silex. This looks like the problem could be solved with a .htaccess file, so I added this one, suggested in the official documentation:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /fat-silex
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
However, it doesn't seem to have any effect at all.
Your rewrite base should be /fat-silex/web
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /fat-silex/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I've tested it on my localhost, and it works fine
the problem is your apache conf. If you don't use virtual host you should configure apache to allow htaccess file of your project directory.
On Linux (Ubuntu) : sudo vi /etc/apache2/sites-available/default
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
...
</Directory>
<Directory /var/www/fat-silex/>
AllowOverride All
</Directory>
I know it is the most repetitive question of CI.
I am using Kubuntu and have made following changes
$config['base_url']='http://localhost/cii/';
$config['index_page'] = '';
$config['uri_protocol']= 'REQUEST_URI';
I've kept my .htaccess file where index.php is kept (in the root folder) but am getting following error:
The requested URL /cii/welcome/second was not found on this server.(404 error)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Possibly the problem is due to the AllowOverride None of document root path in apache sites-available configuration file. You need to modify the line containing AllowOverride None to read AllowOverride All in the file (/etc/apache2/sites-available/default) to make .htaccess files work as expected. Do restart apache once after made the changes.
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Enabling use of Apache htaccess files.
I would guess that the error is because your CI is located at the subfolder /cii but the rewrite rules point to the root folder.
Try adding RewriteBase /cii/ inside the first block.
I've setup CodeIgniter for my desktop version of the website for the first time, and I'm having a little problems after changing AllowOverride from None to All so that the following .htaccess rules work:
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|m|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
The problem is, I have a mobile version of the website located at m.domain.com - which pulls its content from domain.com/m. When AllowOverride was 'None', this worked perfectly. Now that I've changed it to 'All' and implemented the above .htaccess file - the subdomain no longer works and I get a "Test Page for the Apache Server" html file displayed.
Anyone have any idea what could be causing the problem?! Thanks!
Why do you AllowOverride All for just one htaccess file when you could embed it in the vhost conf and go back to AllowOverride None where things seems to work better for you ?
On a side note AllowOverride All is something you usually try no do to.
Example :
<VirtualHost *:80>
ServerAlias yourdomain.com
DocumentRoot /var/www/
<Directory "/var/www/folder">
RewriteEngine On
RewriteRule XXXXXX
</Directory>
<Directory "/var/www/another">
RewriteEngine On
RewriteRule XXXXXX
</Directory>
</VirtualHost>