Avatar of nccguys
nccguys asked on

Help with mod_rewrite on GoDaddy

I am testing my software on GoDaddy's servers and it is functioning very strange.
 
This software works okay on other 'LAMP' type servers with mod_rewite installed.  GoDaddy is not offering any helpful support on this.  They just state that they are using the 'normal' apache mod_rewrite module.

The software is PHP/mySQL based and is pulling the 'directory' name (ie. classified, contact, help) from fields in the database.

Here is what's strange. It does not work with some directives in lower case.  

Broke: http://demo4.topclassifiedsoftware.com/classified/Cars-vehicles
Works: http://demo4.topclassifiedsoftware.com/Classified/Cars-vehicles
** Notice the uppercase C in /Classified

Broke: http://demo4.topclassifiedsoftware.com/contact
Works: http://demo4.topclassifiedsoftware.com/Contact
** Notice the uppercase C in /Contact. The url field 'contact' is in lowercase in the database.

Works: http://demo4.topclassifiedsoftware.com/help
Works: http://demo4.topclassifiedsoftware.com/Help
** Notice both of these work. The url field 'help' is in lowercase in the database.

I've attached a copy of my .htaccess .htaccess.txt
Apache Web Server

Avatar of undefined
Last Comment
nccguys

8/22/2022 - Mon
Frank Contrepois

Use the [NC] in your rewrite rules

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriteflags

RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?pid=$1 [NC]
RewriteRule ^([a-zA-Z0-9_-]+)/?([a-zA-Z0-9_-]+)/?$ index.php?pid=$1&mode=$2 [NC]
RewriteRule ^([a-zA-Z0-9_-]+)/?([a-zA-Z0-9_-]+)/?([a-zA-Z0-9_-]+)/?$ index.php?pid=$1&mode=$2&page=$3 [NC]
ASKER
nccguys

Just tried that, but same results.  Any other ideas?
Frank Contrepois

Filesystems are case sensitive on Unix systems, so rename you files accordingly
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER
nccguys

These are not files I'm browsing to, it's all database generated.

For example, the top navigation which contains links to the /contact and /help mentioned above are created by this command.

      $menu = mysql_query("SELECT * FROM cms_pages where menushow='1' order by weight asc") or die(mysql_error());
      $num_of_pages = mysql_num_rows($menu);      
      $cls = "top_menu";
      if($num_of_pages<=10){
            $cls = "top_menu1";
      }
ASKER
nccguys

Also, on any of my other Linux servers, both these URLs work fine.

http://demo2.topclassifiedsoftware.com/Classified/Cars-vehicles
http://demo2.topclassifiedsoftware.com/classified/Cars-vehicles
** Notice the 'c' in /classified
Frank Contrepois

Going back to basic

http://demo4.topclassifiedsoftware.com/classified/Cars-vehicles
is converted to
http://demo4.topclassifiedsoftware.com/index.php?pid=classified&mode=Cars-vehicles -> OK
http://demo4.topclassifiedsoftware.com/index.php?pid=CLASSified&mode=CARs-vehicles -> OK

so pid and mode are insensitive.

http://demo4.topclassifiedsoftware.com/Classified/CARS-vehicles -> OK
so only the first (pid) part of the Rewrite is having troubles

I cannot see any error on that line so here my next tries:
use /index.php?pid.... instead of index.php (without the initial /)
try the following line RewriteRule ^([ca-zA-Z0-9_-]+)/?([a-zA-Z0-9_-]+)/?$ to check for a rewrite bug on c letter (?_?)
another try RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?pid=$1&mode=$2 (the in between / is needed)
another try remove the initial ^

but that's just guessing

Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Frank Contrepois

Frank Contrepois

Sorry for the last comment, it looks like any uppercase letter in the pid part got the thing to work
Frank Contrepois

Last idea:
RewriteRule ^([a-z0-9_-]+)/([a-z0-9_-]+)/?$ index.php?pid=$1&mode=$2 [NC]

using the NC and removing A-Z
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER
nccguys

Thanks for the help so far.  None of the combinations seem to be working.  Here's the last two I tried.


RewriteRule ^([a-z0-9_-]+)/?$ index.php?pid=$1 [NC]
RewriteRule ^([a-z0-9_-]+)/([a-z0-9_-]+)/?$ index.php?pid=$1&mode=$2 [NC]
RewriteRule ^([a-z0-9_-]+)/?([a-z0-9_-]+)/?([a-z0-9_-]+)/?$ index.php?pid=$1&mode=$2&page=$3 [NC]

RewriteRule ^([a-z0-9_-]+)/?$ /index.php?pid=$1 [NC]
RewriteRule ^([a-z0-9_-]+)/([a-z0-9_-]+)/?$ /index.php?pid=$1&mode=$2 [NC]
RewriteRule ^([a-z0-9_-]+)/?([a-z0-9_-]+)/?([a-z0-9_-]+)/?$ /index.php?pid=$1&mode=$2&page=$3 [NC]
Frank Contrepois

just to try, use (.*) instead of ([a-z0-9_-]+)
ASKER
nccguys

Might be on to something.  This 'kinda' works now.

I'm not getting any error messages, but the 'paths' are not pulling correctly.  Images and CSS aren't pulling.

Take a look now:
http://demo4.topclassifiedsoftware.com/classified/Cars-vehicles
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Frank Contrepois

try like this, just to investigate where the problem is

RewriteRule ^([a-z]+)/?([a-zA-Z0-9_-]+)/?$ index.php?pid=$1&mode=$2 [NC]
ASKER
nccguys

No error message, but still no image/css

Here's the .htaccess now, just to make sure it looks right.

      RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)/?$ index.php?pid=$1 [NC]
      RewriteRule ^([a-z]+)/?([a-zA-Z0-9_-]+)/?$ index.php?pid=$1&mode=$2 [NC]
    RewriteRule ^(.*)/?(.*)/?(.*)/?$ index.php?pid=$1&mode=$2&page=$3 [NC]
Frank Contrepois

RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?pid=$1 [NC]
      RewriteRule ^([a-z]+)/?([a-zA-Z0-9_-]+)/?$ index.php?pid=$1&mode=$2 [NC]
    RewriteRule ^([a-zA-Z0-9_-]+)/?([a-zA-Z0-9_-]+)/?([a-zA-Z0-9_-]+)/?$ index.php?pid=$1&mode=$2&page=$3 [NC]


for now let's concentrate on the line
RewriteRule ^([a-z]+)/?([a-zA-Z0-9_-]+)/?$ index.php?pid=$1&mode=$2 [NC]
and the http://demo4.topclassifiedsoftware.com/classified/CARS-vehicles/ 
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER
nccguys

RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?pid=$1 [NC]
RewriteRule ^([a-z]+)/?([a-zA-Z0-9_-]+)/?$ index.php?pid=$1&mode=$2 [NC]
RewriteRule ^([a-zA-Z0-9_-]+)/?([a-zA-Z0-9_-]+)/?([a-zA-Z0-9_-]+)/?$ index.php?pid=$1&mode=$2&page=$3 [NC]

Error / Not Found
http://demo4.topclassifiedsoftware.com/classified/Cars-vehicles

No Error, but no image/css
http://demo4.topclassifiedsoftware.com/Classified/Cars-vehicles
ASKER CERTIFIED SOLUTION
Frank Contrepois

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
nccguys

A little better now.  Most of the site is coming up now without errors.  Only the 'content' area is not being displayed.  What do you see on your end?
Frank Contrepois

On ipad looks like it works
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
nccguys

I checked on iPhone and it looks the same as browser.  Take a look at http://demo2.topclassifiedsoftware.com to see what it should look like.

I see all of the 'template' area, just not content.
Frank Contrepois

no more ideas for now :(
as you said it looks like a bug of rewrite module
Frank Contrepois

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER
nccguys

Well you got me a lot closer than before.  I'm going to award you the solution for this because we are not getting the error at least.  Thank you very much for the help with this!!