Forum Moderators: phranque

Message Too Old, No Replies

Unusual .htaccess problem

         

catch2948

4:10 am on Apr 27, 2005 (gmt 0)

10+ Year Member



I'm currently trying to setup a cms that uses php and mod_rewrite to call certain directories that are actually files (ie - www.my-domain.com/widgets/). However, I can't seem to get the .htaccess lines correct.

Below is the .htaccess setup that was included in the help.txt file:

<Files widgets>
SetHandler application/x-httpd-php
</Files>

RewriteEngine On
RewriteBase /

AddType text/xml .xslt

RewriteCond %{REQUEST_URI}!widgets\.php
RewriteRule ^widgets(.*)$ widgets.php$1

Can anyone tell me what the problem is?

As always, thanks in advance for your replies :-)

jd01

6:23 pm on Apr 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi catch2948,

I think this one has been left alone, because there is nothing glaringly wrong.

I would comment out everything except:
RewriteEngine on
RewriteCond %{REQUEST_URI}!widgets\.php
RewriteRule ^widgets(.*)$ widgets.php$1

and make this small change:

RewriteEngine on
RewriteCond %{REQUEST_URI}!widgets\.php
RewriteRule ^widgets(.*)$ /widgets.php$1

See if this works, if it does, you'll know the problem is in one of the other lines... If not, post again, and I'll have another look.

Hope this helps.

Justin

catch2948

7:00 pm on Apr 27, 2005 (gmt 0)

10+ Year Member



Thanks for the reply jd ... Sadly, it didn't work :-(

Someone did tell me however, that the error was coming from how php was setup on my server, although they couldn't elaborate :-(

jd01

8:30 pm on Apr 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just trying to help you narrow it down...

What was the error?

What do your server logs say?

Has any rewrite ever worked?

Is mod_rewrite installed and is your server httpd.conf file set to AllowOverride File Info, or All

Is your .htaccess in the position to correctly catch and redirect the request to the new location?

Your php or any combination of these (and possibly others) could be the source of the problem.

Justin

catch2948

2:35 am on Apr 28, 2005 (gmt 0)

10+ Year Member



I beginning to think the actual problem is in the script itself ...

I have other rewites that work fine, AllowOverrides is set to All, .htaccess is in the website root ... Server error logs are returning 404 errors everytime I try to access one of the links ...

Thanks so much for your help :-)

jd01

9:14 am on Apr 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can't believe I missed this before...

1. All rules should have [L] (Unless you are really sure otherwise)
RewriteRule ^widgets(.*)$ /widgets.php$1 [L]

2. If you don't want to go through logs to try to find out why/where the rule is sending you to get a 404, you could try:

RewriteRule ^widgets(.*)$ /widgets.php$1 [R,L]

The [L] indicates last rule, stop processing.

The 2nd rule with [R,L] will execute an external redirect (visible in the browser). When I run into 404's, or other issues I often switch to an external redirect, so I can see where the rule is trying to send me. Then, after I have the problem solved, I remove the R and switch back to an internal redirect. (This is often much faster/easier than reading logs, for me anyway.)

Sorry I missed the [L] before, should know better.

Justin

catch2948

11:33 am on Apr 28, 2005 (gmt 0)

10+ Year Member



That did the trick! I Also needed to add the following line to the top of my .htaccess file:

AcceptPathInfo On

Everything works great now ...

Thanks again :-)