Server Details:
FreeBSD
PHP Version 4.3.11
Apache
Appache Modules:
mod_throttle, mod_php4, mod_speedycgi, mod_ssl, mod_setenvif, mod_so, mod_unique_id, mod_headers, mod_expires, mod_auth_db, mod_auth_anon, mod_auth, mod_access, mod_rewrite, mod_alias, mod_actions, mod_cgi, mod_dir, mod_autoindex, mod_include, mod_info, mod_status, mod_negotiation, mod_mime, mod_mime_magic, mod_log_config, mod_define, mod_env, mod_vhost_alias, mod_mmap_static, http_core
The issue I am having is when ever I write any kind of code in the .htaccess file, it throws a 500 Internal error
I am simply trying to rewrite url's and am using the exact code that wordpress creates for me and even tried custom code used before on previous servers and it still does not work.
WordPress created code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /lobster-tail-blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /lobster-tail-blog/index.php [L]
</IfModule>
# END WordPress
And even a simple thing like this throws the error:
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>
Anyone know of any fixes or why this is causing this error? I have the mod_rewrite module loaded
You should take a look at AllowOverride it is probably turned off try something like this:
<Directory /path/to/www/root/>
AllowOverride All
</Directory>
Related
I've tried almost every possible option with .htaccess file in my lumen's public folder but non of them are giving me Pretty URLs.
In previous versions of Lumen I hadn't touched any of the .htaccess rules and yet everything used to work perfectly with the shipped default .htaccess file.
But in this new version 5.2 nothing seems to work.
the default is as follows :
# Apache configuration file
# http://httpd.apache.org/docs/2.2/mod/quickreference.html
# Note: ".htaccess" files are an overhead for each request. This logic should
# be placed in your Apache config whenever possible.
# http://httpd.apache.org/docs/2.2/howto/htaccess.html
# Turning on the rewrite engine is necessary for the following rules and
# features. "+FollowSymLinks" must be enabled for this to work symbolically.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
</IfModule>
# For all files not found in the file system, reroute the request to the
# "index.php" front controller, keeping the query string intact
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Any thoughts ?!
In you apache config file (httpd.conf or apache2.conf) you must change the "AllowOverride" to "All":
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
I'm having a problem with a script. It doen't works with a htaccess file that is needed to work. Here's what the htaccess contains. I'm trying to install it on a wamp localhost. The code is:
#AddType x-mapp-php5 .php
#AddHandler x-mapp-php5 .php
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
#RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
Options All -Indexes
If I remove this it works:
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
#RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
But this way the script loads but every page show error 404. Is there a way to resolve this problem??
It looks like you don't have the rewrite modules loaded. Find your httpd.conf file and make sure this line (or something similar) is uncommented:
LoadModule rewrite_module modules/mod_rewrite.so
Check that you have the the apache rewrite module loaded.
go to wamp_manager -> apache -> modules and look for rewrite_module in the list.
If it does not have a TICK beside it click it. Apache will be bounced ( stop, start ). Try again.
The rewite engine will not work without the required module loaded.
I had the same problem. To un-comment the line, remove the # in front of the line
LoadModule rewrite_module modules/mod_rewrite.so
Worked for me in Wamp.
Directory of the httpd.conf file: C:\wamp\bin\apache\apache2.4.9\conf
This is one solution that solved the issue for me. Rewrite module was always enabled, used in IfModule rewrite_module, permissions were granted and .htaccess contents were fine, yet it still was 500 error trying to use rewrite module.
In httpd.conf by default:
This is a source of a 500 error if you try to use rewrite in .htaccess in some sub directory.
`
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all denied
</Directory>
`
So one may want to use .htaccess with rewrite module in a specific directory. You would add a <directory> block for that directory. If one copies and pastes the directory block, you need to make sure the intent of the block you copy is correct for the directory you want to apply it to.
So for my intent this block, causes a 403 error, but does get rid of the 500 error.
<Directory "c:/Apache24/htdocs/store">
AllowOverride All
Options None
Require all granted
</Directory>
Changing to this solved the issue:
<Directory "c:/Apache24/htdocs/store">
AllowOverride All
Require all granted
</Directory>
I suppose this is why the issue is commonly seen, but rarely solved in these threads. If I simply copied a different block, typed my own block, or had any understanding of what I was doing, this wouldn't have been an issue.
I can't say this solves everybody's issue, but I hate when people solve-and-run w/o enlightening the rest of us. So for those that did my mistake, this is the answer.
I think somehow most of us had a trouble with .htaccess I d'like to know if someone can help me.
Opensuse 12.3 :
Code:
Linux linux-hyo0.site 3.7.10-1.16-desktop #1 SMP PREEMPT Fri May 31 20:21:23 UTC 2013 (97c14ba) x86_64 x86_64 x86_64 GNU/Linux
I d'like to install Cakephp on my machine but I have an error on my webpage saying that "
Code:
URL rewriting is not properly configured on your server.
"
my /etc/sysconfig/apache2 file as this :
Code:
APACHE_MODULES="authz_host actions alias auth_basic authz_groupfile authn_file authz_user autoindex cgi dir include log_config mime negotiation setenvif status userdir asis imagemap php5 reqtimeout authz_default rewrite"
and the /etc/apache2/sysconfig.d/loadmodule.conf as this line at the end
Code:
LoadModule rewrite_module /usr/lib64/apache2/mod_rewrite.so
I did also change my file etc/apache2/defaul-server.conf
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory "/srv/www/htdocs">
Options Indexes FollowSymLinks MultiViews
AllowOverride ALL
Order Allow,Deny
Allow from all
</Directory>
Any help?
on app/webroot
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
and on app/
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
This is quite an old question but maybe this answer is relevant for you Google users out there:
Did you change the View/Layouts/default.ctp?
This is what happens with this warning:
The warning is set in a div in View/Pages/home.ctp
In home.ctp only sets the warning when the file app/webroot/css/cake.generic.css exists
In the standard default.ctp layout, the stylesheet /css/cake.generic.css is loaded
In cake.generic.css the div with the warning is.... hidden!!!
So what happens when the default home page loads: it tries to load the cake.generic.css style sheet, which succeeds when mod_rewrite is configured correctly. So then the warning is hidden. If it fails to load the style sheet, the warning will stay visible.
This warning pops up, in short, when either there is a problem with mod_rewrite and htaccess, or you changed the layout so that the cake.generic.css is no longer loaded...
First check if you even try to load the stylesheet. Does it show up in your F12 console?
After hours trying to track down the problem I finally found that my .htaccess file never existed in the first place. I copied the following code into a new .htaccess file and hey presto.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Let me first say: I HATE CAKEPHP!!!!
I just spent hours working on this issue.
I learned that cake tests URL rewrite by checking for app/webroot/css/cake.generic.css
Make sure that exists.
My solution came after I checked the apache error_log and saw it complaining about not being able to find http:/myproject/css. Well, there is no css directory there by default. I created a link (ln -s app/webroot/css) and it solved Cake's problem.
If you got this error after new installation of Cakephp and you do not changed any of the files(css files or cake.generic.css) then do the following:
sudo a2enmod rewrite
sudo service apache2 restart
sudo nano /etc/apache2/sites-available/000-default.conf
Look for “DocumentRoot /var/www/html” and add the following lines directly below:
AllowOverride All
sudo service apache2 restart
Make sure you change all AllowOverride None to AllowOverride All
I have this problem and solve this copying the lines of cakebook:
http://book.cakephp.org/2.0/en/installation/url-rewriting.html
There is also a .htaccess file in the root folder, i.e. /.htaccess. This may not have been copied across as it's hidden by default by most operating systems.
Try adding this as the contents of /.htaccess and checking it makes it to the web server.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
There's more explanation at http://book.cakephp.org/2.0/en/installation/url-rewriting.html
There’s two solutions:
1) Either set the DocumentRoot in your Apache configuration file to the app/webroot/ directory, and CakePHP will use the .htaccess file there.
2) Place a .htaccess file in the root of your application, as by default I don’t think one gets created if you use the CakePHP console to generate an app. That .htaccess file should look this this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
I have a problem with the mod_rewrite module for Apache 2.2
My code will neither work on localhost (Wamp on Win8 Pro, IPv6) nor on the webhotel (site5.com).
My goal is to generate SEO friendly URLs as:
www.xy.com/featured-artists.html
instead of:
www.xy.com/index.php?pageID=Artists
The PHP variable $pageID is defined on line 1 in my index.php:
<?php isset($_GET['pageID']) ? $pageID = $_GET['pageID'] : $pageID = 'Forside';?>
The code for the rewrite in my .htaccess file looks as follows:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^([^/.]+)/?$ /index.php?page=$1
</IfModule>
Unfortunately that doesn't have any effect on the site. The .htaccess file is working properly though, since other sections like
ErrorDocument 404 /index.php?pageID=404
work as expected.
No matter what I do - it won't work. So I really hope that some of you can help me with that.
Thanks!
Mod_rewrite doesn't seem to be turned on. Your rules are inclosed in a IfModule container:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^([^/.]+)/?$ /index.php?page=$1
</IfModule>
So the rules aren't going to get executed. You need to turn on mod rewrite in server config (or your webhost) if you want any of your rules to work. Otherwise, it doesn't matter what you try.
Once you had mod_rewrite loaded, your rules should do close to what you want. It'll take /something and internally rewrite it to /index.php?page=somethin.
I am attempting to move my Codeigniter projects from a shared hosting service to Amazon EC2 and am running into some challenges with my .htaccess settings. These settings enabled me to not have to include index.php in the url. My previous .htaccess is shown below and worked as expected with my previous hosting provider:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /simple.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
With my Amazon EC2 instance, I now have full access to the LAMP stack and have confirmed that the Apache Mod_Rewrite module is enabled.
I have set up my EC2 instance with two Virtual Host directories, one for each of my sites. Both sites serve up their CI applications as expected, but require index.php to be in the url.
I've tried inserting my Amazon EC2 public path into the .htaccess file as follows but still no luck:
RewriteBase /ec2-55-27-191-14.compute-1.amazonaws.com/simple/
I am sure this is 100% user error on my part and would greatly appreciate your diagnosis!
To answer my own question...
I wound up changing the Apache file /etc/apache/sites-available/default from AllowOverRide = None to AllowOverRide = All.
have you also tried
RewriteBase /
or RewriteBase /simple/
or along those lines?
in my dealings on servers i've used, i've never had to put the domain into the rewrite base. Just the folders