Rewrite rules not working on goDaddy server

Trying to get this to work on godaddy but it’s not, any ideas? I’ve done a lot of googleing but all the options (turn multi-view off, rewrite base, follow syslinks) have failed. Anyone have any experience with this? This is just a CMS I made. It works on several other servers, so I’m a little lost as to why it’s not working. I did do the mod_rewrite is enabled test and it worked so no idea whats the issue. I get the 500 internal server error.


RewriteEngine On
RewriteRule ^feed.xml feed.php [L]
RewriteRule ^([a-z0-9-_]+)$ page.php?theurl=$1 [L]
RewriteRule ^([a-z0-9-_]+)/([a-z0-9-_]+)$ page.php?theurl=$1/$2 [L]
RewriteRule ^([a-z0-9-_]+)/([a-z0-9-_]+)/([a-z0-9-_]+)$ page.php?theurl=$1/$2/$3 [L]

Thanks for any and all help.
Justin

p.s. if anyone who knows mod_rewrite better than me could help me condense that into one line, that would be amazing. I tried once before but failed and haven’t tried since. Once this project gets launched it’s one of my next goals.

godaddys apache version is 1.3.33 where all the other servers i’ve tested on are 2.x, looking into possible mod_rewrite issues, if anyone has any info please let me know!

14th,

Have you read the sticky posts or my signature’s tutorial? Apache 1.x requires a / after ^ while Apache 2.x requires it NOT be present. If you use ^/?, that will work for both flavors of Apache.

Regards,

DK

dkylnn, not recently no. sorry i just recently thought to look at apache versions. i bascially picked up what i needed to learn for the project (over a year and a half ago) and haven’t investigated since. sorry for my incompetence.

I’ve tried both /? and / after the ^ and no dice sadly.
currently I’m in a subdomain, the htaccess im editing is in the folder that represents that subdomain: beta.domain.com points to domain.com/beta
so the htaccess is in the beta folder, not sure that matters. to my understanding subdomains are treated as new domains in terms of paths.

ok…so confused, i must of tested the wrong server, this test no longer works: http://www.wallpaperama.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html

but the mod_rewrite doesn’t throw the 500 internal server error, but mine does… godaddy says it has mod_rewrite enabled though @.@

Justin,

For the time being, please use ^/? (because it’ll work on all Apache servers.

Incompetence? Naw, just a learning experience. You don’t know how I “bled” learning about the “missing support files” problem (different directory level in a redirection makes relative links miss their targets).

Yes, indeed! Subdomains (if used in the URL) ARE different domains. Some hosts, however, will EXTERNALLY redirect the subdomain to the main domain’s subdirectory (which, IMHO, is BAD because it breaks the intent of the webmaster to have a separate domain).

Sorry, I don’t understand the ‘doesn’t throw a 500 error but mine does.’ HOWEVER, because a dash is a metacharacter within a character range definition, it should be listed FIRST (last seems to work, too) and NEVER in the middle of some other characters (you have it defining a character range from 9 to _ - from 39 to 5F!).


RewriteEngine On
RewriteRule ^feed.xml feed.php [L]
RewriteRule ^([a-z0-9-_]+)$ page.php?theurl=$1 [L]
RewriteRule ^([a-z0-9-_]+)/([a-z0-9-_]+)$ page.php?theurl=$1/$2 [L]
RewriteRule ^([a-z0-9-_]+)/([a-z0-9-_]+)/([a-z0-9-_]+)$ page.php?theurl=$1/$2/$3 [L]

=>


RewriteEngine on
RewriteRule ^feed.xml feed.php [L]
RewriteRule ^([-a-z0-9_]+[COLOR="Blue"](/[-a-z0-9_]+[COLOR="DarkOrange"](/[-a-z0-9_]+)?[/COLOR])?[/COLOR])$ page.php?theurl=$1 [L]
 [L]

That’s just grouping successively optional atoms inside the next one. Note that the blue atom is optional but the -'s, lowercase letters and _'s must be present for the optional gold atom to be present. Because they’re all included in the first atom, $1 is all you need to reference for the value of theurl.

Regards,

DK

ok I got most of that…lol I see why you got the server/apache guru 2010 award =P
I’m waiting on GoDaddy to respond but I may have one issue and I’m not sure why. I can’t rule out anything till I get mod_rewrite enabled. (the issue is due to some poor writting on my part earlier in the project, i allowed a double - to appear: e.g. ‘/about/officers–directives’. I get ‘No input file specified.’ as an error).

But with the new code you provided I am not getting the ‘500 Internal Server Error’ I was getting earlier. I see the actual site (woot!) sans mod_rewrite pages.

You lost me here: 'Note that the blue atom is optional but the -'s, lowercase letters and _‘s must be present for the optional gold atom to be present.’ I understand they are optional due to the ? there but after that I got lost.

What I meant by ‘doesn’t throw a 500 error but mine does.’ was simply how could 1 rule break the server but not the other if its not enabled. Sorry for that.

I greatly appreciate your help. Hopefully godaddy will get back to me today.

Thx again,
Justin

Justin,

It’s all in what you’ve been exposed to - and remember. :lol:

Double dashes, eh? The character range definition can easily handle that as there’s no ordering, just matching of a range of specified characters.

Each of those character range definitions are [-a-z0-9_]+ which means (+) one or more of the preceding character with the character being defined as a - ([-]), as lowercase letters ([a-z]), digits ([0-9]) and underscores ([_]). I was just verbalizing the characters specified by MY character range definition.

Don’t be sorry, just trying to improve communications (so I can explain something which needs explained).

Regards,

DK

Ya I’m not sure why it’s breaking on the double dash at the moment. I know the character range can handle it. I have no where in my code that would output that error message…its an unknown atm…

Oh just curious. You said to use /? in after ^ but in the code you gave me, it’s absent:


RewriteEngine on
RewriteRule ^feed.xml feed.php [L]
RewriteRule ^([-a-z0-9_]+(/[-a-z0-9_]+(/[-a-z0-9_]+)?)?)$ page.php?theurl=$1 [L]

Shouldn’t it be

RewriteEngine on
RewriteRule ^/?feed.xml feed.php [L]
RewriteRule ^/?([-a-z0-9_]+(/[-a-z0-9_]+(/[-a-z0-9_]+)?)?)$ page.php?theurl=$1 [L]

or am I mis-understanding?

GoDaddy said they have it enabled yet it’s not working…I think I’m going to get the client to move hosts.

Apparently I missed the edit time:

I don’t think the code is working properly. Er I’m not really sure what’s the matter. It seems anything deeper than 1 layer is not working. e.g. about/officers–directives didn’t work so i went to just test and got rid of the double – and it still didn’t direct to page.php properlly. What’s really strange is instead of giving me something blank it gave me about.php content. About.php is a physical page and not a page.php generated page.

so: about/officers-directives and about/officers–directives goes to about.php rather than page.php

**edit
/sigh/frustration/wrist
could it be the subdomain is messing things up? my backup htaccess works on a base lvl staging server (test site) but not on subdomains it looks like. (this also includes the new code)

it’s not the subdomain, thats all i know

Sorry to keep adding to this, but this may give some insight as this is bazaar. So the rewrite rule reads:

/press-releases/12-23-2010/press-release-name
but ignores:
/about/officers–directives

I wrote this rule:


RewriteRule ^/about/officers--directors index.php [L]

It ignores it. It appears to ignore the about section… I got rid of all rules and still went to the page and it led to about.php

It appears to be taking the ‘about’ in the url (/about/officers–directives) and matching it to about.php

Update
ok figured something out, its hitting the php files before it hits the mod_rewrite (why?) looking it up. I tested this by making a press-releases.php file and sure enough that press release link broke and the url redirected to that.

looks like the winner is:
Options +FollowSymlinks
Options -MultiViews

Sorry, I’m not used to the fact that there are any 1.x versions still out there in the wild so I automatically code for Apache 2.x.

What your last post described in the main problem with “MultiViews”, i.e., an Apache core “feature” which allows a filename (apparently without extension) in the path to {whatever} which intercepts and serves the file, in your case, about.php.

Options -MultiViews

should take care of that annoyance for you.

Regards,

DK

yep i got it, thx for all of your help. =D