.htaccess causing 500 error - php

I have only a single line in the .htaccess file:
RewriteEngine On
Taking that line out makes the error go away. I've checked as many places as I know of for the AllowOverride rule (but I know next to nothing about how that works) and I thiiiiink it's set correctly, but I don't know for sure.
I can't figure out what's going on and I'm not sure what to even check. Any ideas? Thanks in advance.

Enable the rewrite module in apache by command on ( for Ubuntu )
sudo a2enmod rewrite

Try replacing it with:
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule

Related

htaccess IfModule conditional fails

I have a basic .htaccess file.
If I leave it empty the page loads correctly.
If I have a conditional statement in there (e.g.:)
<IfModule mod_filter.c>
#Intentionally left blank
</IfModule>
I get a 500 error.
So even though the mod_filter exists and is loaded it dies. Even though there is nothing in the IfModule statement.
It's almost as if the <IfModule> statement itself isn't working.
This is on 32bit WAMP on Windows.
I have other sites running locally that do have full htaccess files, and they work, but this one just won't play!
Any one seen this before?!
Remove a space after mod_filter.c :)
You just need to remove the space as shown below after mod_filter.c
<IfModule mod_filter.c>
#Intentionally left blank
</IfModule>
This was due to a corrupted file. Recreating the file worked.

CakePHP missing controller on EC2

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.

Perplexing .htaccess/PHP Conundrum

So... I finished a site on my local server, and I uploaded it to my remote server.
Going to the remote site yields an Internal Server error. I think there might be something wrong with the .htaccess file. Here's what it contains:
Options All -Indexes
Options +FollowSymlinks
DirectoryIndex launcher.php
IndexIgnore */*
RewriteEngine ON
RewriteRule ^(.*)\.less$ $1.css.php [nc]
RewriteRule ^([A-Za-z]+)$ launcher.php?page=$1 [QSA,L]
Eventually, I tried to debug the problem by adding # before the DirectoryIndex line to see what would happen. The result:
403 Forbidden
You don't have permission to access /site/ on this server.
Which is puzzling, because all the permissions seem to be ok... I double checked, the .htaccess file has octal 644.
What could be causing this issue? Thanks for any responses in advance.
Thanks to the help SO users, my problem was solved.
Apparently, Apache freaks out if the .htaccess file has permissions set to write, so I was able to fix the problem by chmoding the entire directory and everything in it to 755.
I had the same problem and as the error message says, the file mentioned was having permission 664. I just removed the write permission for group and the permission became 644. That fixed the error.

PHP rewrite giving 404, .htaccess problem?

I have the following .htaccess:
#Options +FollowSymLinks
RewriteEngine on
RewriteBase /phptest
on my local testing server (http://localhost) I have to uncomment the first line for the site to work. Otherwise I get Error 403 (Forbidden).
Once I upload the page to my webserver (FastHosts) I get Error 500 (Internal Server Error) if the first line is not commented out.
If I comment it out, my page loads but it cannot find the page content which is mydomain.com/phptest/Home
I get a 404.
Any suggestions on what the problem might be?
Check for mod_negotiation to be disabled. It gives unexpected results in combination with mod_rewrite.
I think you need to modify your httpd.conf to allow for AllowOverride All
What does your error log say?
Can you please check whether mod_rewrite is enable or not in your php.ini file. If not then please enable that.

Apache Url Rewriting won't work

In the httpd.conf file I have AllowOverride FileInfo. In the .htaccess file in top level of my webserver with all the other files, I have this:
RewriteEngine On
RewriteRule ^downloads/?$ index.php?page=downloads [L,NC]
But it doesn't work. mywebsite/downloads and mywebsite/downloads/ always give a 404 not found. Any idea why? Thanks. (mywebsite/index.php?page=downloads does work).
And I'm restarting apache every time I change it.
And when I put the code above in httpd.conf, the website won't even load at all, just blank, spinning safari wheel forever.
Its fine if I just do RewriteEngine On, but if I do anything else (RewriteBase, RewriteRule), the web browser spend ages trying to load and finally giving this error:
Safari can’t open the page “http://mk12.gotdns.com/” because the server where this page is located isn’t responding.
Anyone have any idea what's wrong?
EDIT: I'm able to make, for example, css files forbidden with rewrite, and it works, but any rule that goes from downloads to index.php?page=downloads makes the server not respond (see above), it doesn't matter what page, the website won't load at all. Any ideas..?
The best way to debug rewrite rules is to enable rewrite logging so you can see what's going wrong.
It Worked!! I was putting the code in the wrong spot. It was in httpd.conf, but at the end. Move it into <Directory> and its good. Thanks for your help!
EDIT: Also, I found that It won't work if the flags are like this: [L, NC]. It has to be [L,NC] (no spaces).
So the two problems where that it wasn't inside <Directory "/Library/WebServer/Documents">, and there were spaces between the flags. Hopefully this will help someone else in the future.
Have you tired adding a slash in front of the "download" like below
RewriteRule ^/downloads/?$ index.php?page=downloads
EDIT: Try the code below:
RewriteEngine On
RewriteBase /
RewriteRule ^downloads/?$ /index.php?page=downloads
I would try removing the trailing slash and question mark after downloads, and the leading slash before index.php.
RewriteEngine On
RewriteBase /
RewriteRule ^downloads$ index.php?page=downloads.

Categories