Page 1 of 2
.htaccess file causing Server Error
Posted: Sun Jan 08, 2012 10:06 am
by simonmlewis
Hi
I am trying to work on Short Urls, so am changing settings to I can have a local url setup properly.
http://testingsite.local
Problem is it doesn't direct to the full URL, so I have added the HTACCESS file in there
Code: Select all
DirectoryIndex index.html index.htm index.php
order allow,deny
allow from all
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteRule ^$ index.php?page=home&menu=home [L]
And this immediately causes:
Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the webmaster.
I've setup the hosts file. So not sure what's causing it. any ideas?
EDIT: mod rewrite rule is loaded, according to PHP Info.
Re: .htaccess file causing Server Error
Posted: Sun Jan 08, 2012 2:01 pm
by Christopher
Check the docs, but I think there are some configuration options you need to allow to have rewrite work. Check AllowOverride for things like AuthConfig. FileInfo, Options, etc.
Re: .htaccess file causing Server Error
Posted: Sun Jan 08, 2012 2:52 pm
by simonmlewis
Sorry but you are talking greek to me.
Please if you could explain exactly what to look for, and where, and the setting things should be on, as I have not a clue.
I am trying to learn the mod rewrite, but until I can get this basic this running, I'm stuck.
Re: .htaccess file causing Server Error
Posted: Mon Jan 09, 2012 1:11 am
by Christopher
The problem may not be with your rewrite rules, it may be that your server dies on .htaccess files. You need to configure Apache first to allow you can set things in .htaccess files.
Re: .htaccess file causing Server Error
Posted: Mon Jan 09, 2012 4:42 am
by simonmlewis
Lovely - how?
Re: .htaccess file causing Server Error
Posted: Mon Jan 09, 2012 5:03 am
by twinedev
By changing settings in httpd.conf is one sure way. You have to remember, we do not already know how your server is currently set up and they can be set up tons of different ways.
Search documentation and then the file for settings of "AllowOverride" to see what they are set for.
Just because mod_rewrite is enabled, doesn't mean that other options/settings in .htaccess are not allowed.
Is this your own server setup? Are you trying to do this on a hosting plan somewhere?
Re: .htaccess file causing Server Error
Posted: Mon Jan 09, 2012 5:08 am
by simonmlewis
I am trying to do this locally first. I use XAMPP for my Apache/PHP web site running.
I managed to get virtual hosts running, so for example:
http://clienta.local works! And I could put
http://clienta.local/index.php?page=home.... that works too.
Where in XAMPP should I look (file and folder would really help) to see where this AllowOverride should be, or where to add. If I can get htaccess running, I think I can possibly work thru tutorials to get tinyurl running.
Re: .htaccess file causing Server Error
Posted: Mon Jan 09, 2012 5:13 am
by simonmlewis
Code: Select all
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
I just found this in httpd.conf.
Could this be the cause: Allowoverride *none* ???
Shouldn't that be set to All ??
Re: .htaccess file causing Server Error
Posted: Mon Jan 09, 2012 5:14 am
by twinedev
Dunno in XAMP, have no idea, I've only worked directly with servers, My guess on that screen shot would be the Setup button?
Re: .htaccess file causing Server Error
Posted: Mon Jan 09, 2012 5:25 am
by simonmlewis
This is what is shown on that setup button.
All leads said it is the AllowOverride to be "All", but that did not work, even after a restart.
It *MUST* be something in the config that disables htaccess from being used locally.
Re: .htaccess file causing Server Error
Posted: Mon Jan 09, 2012 5:30 am
by twinedev
simonmlewis wrote:Code: Select all
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
I just found this in httpd.conf.
Could this be the cause: Allowoverride *none* ???
Shouldn't that be set to All ??
No, that is the correct setting for the root of the system. There should be a similar block elsewhere that is for the root of your webdocs.
-Greg
Re: .htaccess file causing Server Error
Posted: Mon Jan 09, 2012 5:38 am
by simonmlewis
Code: Select all
<Directory "C:/xampp/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks Includes ExecCGI
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
This?
Happy to upload my config file if it helps.
Just rebooted machine to see if that helped, but it didn't.
BTW it's an "Error 500" if that helps.
Re: .htaccess file causing Server Error
Posted: Mon Jan 09, 2012 5:47 am
by twinedev
That looks ok, so not sure what will be causing it. I took your .htaccess file, put it on my server, and got no error. Sorry can't help you more.
-Greg
Re: .htaccess file causing Server Error
Posted: Mon Jan 09, 2012 5:54 am
by simonmlewis
Ok, I have found the answer!
In httpd-vhosts.conf, is where you have to setup the virtual host.
Even tho AllowOverride All is set in the config file, it also has to go in here.... where the virtual host is setup for each site.
So now I have that line, within the <directory> section and hey presto - WORKS!!
onto the pain of working out tinyurls now.....
Re: .htaccess file causing Server Error
Posted: Mon Jan 09, 2012 7:14 am
by simonmlewis
I have this on another thread, so apologies, but I now have virtual hosts and tinyurl sort of working, but where the url is:
http://clienta.local/page/selector
and the full url would be: index.php?page=selector
All files connected to it, either in images/ or source/, are all being looked for in
page/selector/images/
Why?? How do I get around this.
This is the thread I am trying this on:
viewtopic.php?f=1&t=133229