Forum Moderators: phranque

Message Too Old, No Replies

strange htaccess behaviour

intranet site being odd

         

Matthew1980

8:17 am on Nov 25, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Good morning all!

# Prevent viewing of .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>

# Prevent directory browsing
IndexIgnore */*

# Set the default handler
DirectoryIndex index.php

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(home|add-fault|faults|generate-t-card|view-fault|available|about).html$ index.php?process=$1
RewriteRule ^index.html$ index.php


This mod rewrite/htaccess file I have stripped down to it's relevant parts, this gets parsed fine, yet the links that I have (and have working on other 'live' websites perfectly) don't seem to be processed via this file - in other words, consider this:-

<a href="generate-t-card.html">Start a new card</a>

works with the help of the <base href="the site address here">

unfortunately the structure of the site is like this:

http : //www.example/intranet

which is fine!

so that translates in to this:-

(on mouse over of the links)

http: // www.example/intranet/generate-t-card.html

but in the address bar, the link is parsed and treated like it was a query string link:-

http: // www.example/intranet/index.php?process=generate-t-card

even though it is mod rewrite ready!

I haven't seen this before, so I thought I would post for some help!

Background info, the intranet root dir is on a server, in a users directory and the apache conf files have been set to state that the root IS the directory/folder in my users space on the server, our IT administrator has sorted this out - and he assures me that my .htaccess file is to blame for this...

Thanks for any input!

Cheers,
MRb

g1smd

11:31 am on Nov 25, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Make sure you add the [L] flag to every RewriteRule.

jdMorgan

5:33 pm on Dec 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are seeing the script_filepath+query in the browser address bar, then this indicates that, after the internal rewrite is processed, there is an external redirect being invoked. This external redirect 'exposes' the internally-rewritten filepath as a URL to the client.

I cannot tell from this post whether you have additional directives in this code which may invoke a redirect, or whether the redirect is being invoked by a script -- but there is very likely a redirect occurring which is causing this problem.

It is easy enough to check -- Install and use the "Live HTTP Headers" add-on for Firefox (or similar), and look at the request-response trace to see if there is a 301, 302, 0r 303 redirect to the script_filepath+query path as a URL.

Across your entire server config, from httpd.conf down through the lowest-directory .htaccess file, all external redirects must come first, followed by any internal rewrites. Any other order may cause problems such as you are seeing here.

Jim

Matthew1980

5:46 pm on Dec 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

Thanks for the advice there Jim, I shall check this when I return to work, just got back from vacation, and just found that this had been posted! I'll post back when I see what I am getting.

Cheers,
MRb

Matthew1980

12:23 pm on Dec 18, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Update:

The IT/Mysql admin guy is having a look at something in the .conf file on monday as apparently something in the error log file has caught his attention, though he wont tell me what it was, I suspect that he forgot to add a directive as this dedicated server that runs many other things, not just our intrant. And the root of my intranet website is on our 'users' server which is deep in the server somewhere and not a root of some obscure drive. So I suspect that a file path has been omitted somewhere.

So I hope that once this has been completed on Monday, I shall have a working .htaccess/mod rewrite setup. Fingers crossed!

Cheers,
MRb