I'm deploying a CakePHP (1.3.2) website for the first time. It was hosted on an older server. I received the project as a zip file. I managed to install it on my localhost and made the changes I needed.
Now I have to deploy it to a new server, but I face a problem.
The routing doesn't seem to work. I guess it's an .htaccess issue.
When I access the root folder, it redirects me to /login but then I have a 404:
The requested URL /login was not found on this server.
My 3 main .htaccess files (/, /app and /app/webroot) are the following. (CakePHP is installed at the root of my virtual host)
Root
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
/app
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/app/webroot
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
mod_rewrite seems to be activated on my server as it responds with this when I try to add it:
Module rewrite already enabled
But when I try something simple like that on top of my root .htaccess, it doesn't do anything:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^.*$ test.php
</IfModule>
(I was following this guide: https://docs.bolt.cm/howto/making-sure-htaccess-works)
Among a lot of things, I also tried to add that to all my .htaccess:
Option Indexes
But it didn't help.
Here is my website conf file too:
<VirtualHost xx.x.xx.xx:80>
ServerAdmin xxx#company.com
ServerName xxx.company.com
DocumentRoot /var/www/xxx.company.com
DirectoryIndex index.html index.php
php_value error_log "/var/log/apache2/xxx.company.com-phperror.log"
php_flag register_globals off
<Directory "/var/www/xxx.company.com">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/xxx.company.com-error.log
CustomLog /var/log/apache2/xxx.company.com-access.log common
</VirtualHost>
(I added the Directory section that was not here in the first place)
After a lot of trials, I still haven't found anything that seems to solve my problem.
As I'm definitely not used to work on server side, It might be a simple thing that you will immediately spot. I hope so.
Thanks
I finally got it to work. Here are the two mistakes I made:
I had my document root set cake's root folder instead of the webroot folder. I added /app/webroot after DocumentRoot /var/www/xxx.company.com in my .conf file.
Also, I was using apache's reload function, which is actually not properly reloading. Using service apache2 restart instead does the job.
Related
i have a project running in ubuntu-apache2 with laravel 5.3. The problem is that laravel works on some users but on others it doesn't. When you make the url request the page stays on hold, and you canĀ“t see anything. It's strange because i have users that are using the app normally.
I saw the apache log and i can see the 302 request but not the answer. I change in site-avaible conf the document root to the root path and a I can see the indexes, so i think the problem is in the .htacces file, although I have not made any changes. This is my .conf ->
ServerAdmin serveradmin#serveradmin.com
ServerName localhost
ServerAlias theurlofmypage
DocumentRoot /var/www/html/extranet/public
<Directory "/var/www/html/extranet/public">
AllowOverride All
Options FollowSymLinks Indexes
Order allow,deny
Allow from all
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
And this is the .htacces file:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Can anyone help me??
A 302 is most likely a Laravel response, not an apache thing seeing you redirect with a 301 as far as I can tell.
I had an instance where this drove me nuts too. It happend because I had putten a redirect() somewhere in the code and some requests triggerd it. It redirected back to itself to a part with a wrong namespace which didn't fly.
All I can recommend is temporarily disable middleware and Requests (validation). If that doesn't work try to find all your abort's and redirect()'s.
On my webserver running Apache/2.2.26 (Unix) DAV/2 PHP/5.4.24 mod_ssl/2.2.26 OpenSSL/0.9.8y I am trying to setup Restler but it can't seem to handle the index.php properly. This is a webapp setup with an httpd.conf that looks like so:
Alias "/dts2" "/usr/local/WebApps/DTS/root"
<Directory "/usr/local/WebApps/DTS/root">
AllowOverride All
Options -Indexes FollowSymLinks
</Directory>
So then I went into that 'root' directory and ran this command to install restler:
composer create-project restler/application=dev-basic api --prefer-dist
After that, in the 'api' directory I created my .htaccess file that looks like so:
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ public/index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ public/index.php [QSA,L]
</IfModule>
<IfModule mod_php5.c>
php_flag display_errors On
</IfModule>
And, finally when I try to access "https://..../dts2/api/Home/" to get the success message that restler provides, I get a 404 error.
What have I done wrong?
OK, finally got this working. There were two issues.
One was Restler itself. The supplied index.php said $r->addAPIClass('Home', '');. I had to remove that second empty parameter.
The other was apache. Instead of saying public/index.php on the RewriteRule I had to say /dts2/api/public/index.php.
Once I made those two changes everything worked as expected.
I'm trying to setup Kirby locally using MAMP. My MAMP setup I have it so I can point run multiple sites as virtual hosts. I use this code:
NameVirtualHost *
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "/Users/oscargodson/Dropbox/projects/icarus"
ServerName dev.icarus
</VirtualHost>
When I go to dev.icarus the initial page loads totally fine. All the CSS, images, everything. Once I try to go to a subpage, including the panel, I get the 404. I know for sure the htaccess file is in the folder. I tried using the git install and the manual zip install. I also made sure in in my httpd.conf file I have rewrite turned on
LoadModule rewrite_module modules/mod_rewrite.so
I'm not sure what else to look up. Googling just kept returning results for htaccess file being missing.
EDIT
Here's the htaccess file per request. It is the default one that works if I keep my project inside of the htdocs directory in MAMP. I tried uncommenting the RewriteBase and making it just / (a total guess) but that didn't help at all.
# Kirby .htaccess
# rewrite rules
<IfModule mod_rewrite.c>
# enable awesome urls. i.e.:
# http://yourdomain.com/about-us/team
RewriteEngine on
# make sure to set the RewriteBase correctly
# if you are running the site in a subfolder.
# Otherwise links or the entire site will break.
#
# If your homepage is http://yourdomain.com/mysite
# Set the RewriteBase to:
#
# RewriteBase /
# block text files in the content folder from being accessed directly
RewriteRule ^content/(.*)\.(txt|md|mdown)$ index.php [L]
# block all files in the site folder from being accessed directly
RewriteRule ^site/(.*) index.php [L]
# block all files in the kirby folder from being accessed directly
RewriteRule ^kirby/(.*) index.php [L]
# make panel links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^panel/(.*) panel/index.php [L]
# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]
</IfModule>
# Additional recommended values
# Remove comments for those you want to use.
#
# AddDefaultCharset UTF-8
#
# php_flag short_open_tag on
Mike Rockett in the comments pointed me in the right direction. In the httpd.conf file I had to change
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
</Directory>
to
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
Then I restarted MAMP and it worked!
I am building a web app on top of the symfony2 framework. Everything used to work fine until, due to some problems, i had to wipe the production symfony folder clean and reinstall everything inside the symfony project folder.
Now every request to the server returns a 403, You don't have permission to access / on this server.
Note: the server software is apache2 running on ubuntu.
I deployed using capifony, running cap deploy:setup and cap deploy.
Nothing changed in any apache config files or anything outside the root directory of the symfony project. The server root points to symfonyRoot/current/web, the .htaccess file in that directory looks as follows:
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /app.php/
</IfModule>
</IfModule>
Edit:
from the apache2.conf file:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
from the virtual host config:
<Directory "/var/www/SymfonyRoot/current/web">
Require all granted
AllowOverride All
Allow from All
Options None
</Directory>
I am sure that it is just one simple thing that i am forgetting somewhere, but i can't figure out why the server is denying permission to any routes.
So, i figured out what was wrong:
Options FollowSymLinks was not turned on for the /var/www/SymfonyRoot/current/web folder.
just added Options FollowSymLinks to the .htaccess file and everything works like a charm again!
I have a problem with the domain linked to a folder on my Debian server (with Apache).
(I'll use domain.com for the link of my server hosting the files, and newdomain.com for the domain name I want to link to it.)
Facts
The website consists of .html pages. I have this .htaccess in www.domain.com/subfolder/ for removing the '.html'. The subfolder-folder is where I'm hosting the website on my server.
This works perfect for e.g. www.domain.com/subfolder/photos
RewriteEngine on
#example.com/page will display the contents of example.com/page.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]
#301 from example.com/page.html to example.com/page
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
I bought a .be domain name for the website that is hosted on www.domain.com/subfolder/, let's call it newdomain.be.
I connected it to the server with a vhost and edited the A-records. (And reloaded Apache, ..)
<virtualhost *:80>
# Admin email, Server Name (domain name) and any aliases
ServerAdmin webmaster#newdomain.be
ServerName newdomain.be
ServerAlias www.newdomain.be
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html
DocumentRoot /var/www/subfolder
</virtualhost>
Problem
The DNS-settings are okay, www.newdomain.be works and shows the index.html from my domain.com/subfolder/. But, www.newdomain.be/photos throws a 404! Note that www.newdomain.be/photos.html works as expected, so the problem must be in the Rewriting I guess...
Can someone please explain what I'm doing wrong??
Okay guys, I was finally able to fix it!
Apparently adding a few extra lines in the VirtualHost did the trick :-)
DocumentRoot /var/www/subfolder
<Directory /var/www/subfolder>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
have you checked the file permissions for the new folder ?
try chmod -R command for the /var/www/subfolder/