Page 1 of 1

[Solved] Can't get pretty URLs or modrewrite to work on GoDaddy

Posted: Sun Dec 03, 2006 3:16 pm
by casidougal
I've implemented quite a few CMS MS sites using 1and1 shared hosting and the simple "true" switch in config.php for pretty URLs works great.

However, I'm having to use GoDaddy shared (paid) hosting accounts and no matter what I do, I can't get pretty URLs or a mod rewrite solution to work. I know this issue probably isn't that complex for someone, so please, can someone help me out or point me in the right direction?

I'm using CMS MS 1.0.2 on GoDaddy Shared Linux accounts.

When I switch the pretty URL option in config.php I get 404 errors on all but the front page. Same result when I've tried all the other suggestions I've found for modifying .htaccess and config.php that I found in these places:

Instructions (don't work for me):
http://wiki.cmsmadesimple.org/index.php ... retty_URLs

A post on this same issue using GoDaddy (Solution doesn't work for me)
http://forum.cmsmadesimple.org/index.ph ... l#msg31850

Here are the latest settings I've tried that don't work:
Config.php
---------------------------------------------------------
#------------
#URL Settings
#------------

#Show mod_rewrite URLs in the menu? You must enable 'use_hierarchy' for this to work for modules
$config['assume_mod_rewrite'] = true;

#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '/';

#If you don't use mod_rewrite, then would you like to use the built-in
#pretty url mechanism?  This will not work with IIS and the {metadata} tag
#should be in all of your templates before enabling.
$config['internal_pretty_urls'] = false;

#If you're using the internal pretty url mechanism or mod_rewrite, would you like to
#show urls in their hierarchy?  (ex. http://www.mysite.com/parent/parent/childpage)
$config['use_hierarchy'] = true;

#If using none of the above options, what should we be using for the query string
#variable?  (ex. http://www.mysite.com/index.php?page=somecontent)
$config['query_var'] = 'page';
-----------------------------------------


.htaccess
--------------------------
Options +FollowSymLinks
RewriteEngine on
RewriteBase /

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
----------------------------------

Re: Help! Can't get pretty URLs or modrewrite to work on GoDaddy

Posted: Sun Dec 03, 2006 8:27 pm
by Dr.CSS
You could try these changes...

#Show mod_rewrite URLs in the menu? You must enable 'use_hierarchy' for this to work for modules
$config['assume_mod_rewrite'] = true;

#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '';    deleted the /

#If you don't use mod_rewrite, then would you like to use the built-in
#pretty url mechanism?  This will not work with IIS and the {metadata} tag  this is in the head right?
#should be in all of your templates before enabling.
$config['internal_pretty_urls'] = false;

#If you're using the internal pretty url mechanism or mod_rewrite, would you like to
#show urls in their hierarchy?  (ex. http://www.mysite.com/parent/parent/childpage)
$config['use_hierarchy'] = true;

#If using none of the above options, what should we be using for the query string
#variable?  (ex. http://www.mysite.com/index.php?page=somecontent)
$config['query_var'] = '';    deleted page

Re: Help! Can't get pretty URLs or modrewrite to work on GoDaddy

Posted: Mon Dec 04, 2006 3:58 am
by casidougal
Mark,

Thanks for the advice...unfortunately I'm still getting the same 404 error (BTW I do have the {metadata} smarty tag in all my page templates).

Not Found
The requested URL /how-cmsms-works/pages-and-navigation was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/1.3.33 Server at richardsteeledds.com Port 80


I think I've tried every combination of true/false in the config.php already.

I'm thinking the key to the answer might lie in the .htaccess file somehow? If only I were smarter!

Does anyone else have any ideas to solve this issue? Thanks!

-casi

Re: Help! Can't get pretty URLs or modrewrite to work on GoDaddy

Posted: Mon Dec 04, 2006 4:07 pm
by Pierre M.
As the error essage seems to come from Apache, you should try to tweak Apache/mod_rewrite step by step and then deal with CMSms pretty URLs :

Set up a custom static 404.html page displaying "casidougal is very sorry, but 404". in .htaccess :
ErrorDocument 404 /404.html

Try http://my.server.tld/thereisnodubaya
It should display it. If not your Apache needs a doctor (not CMSms).

Then try a static redirect with a static page :
write /apage.html displaying "what a wonderful static page !"
add the RewriteRule /littlealias /apage.html

Try http://my.server.tld/littlealias
It should display /apage.html If not your mod_rewrite needs a doctor (not CMSms).

If both tests work, what is in the user's guide should work.

If a test fails, please redo it with wget (verbose mode ON) or another browser (not Internet Explorer)

PM

Re: Help! Can't get pretty URLs or modrewrite to work on GoDaddy

Posted: Mon Dec 04, 2006 5:14 pm
by casidougal
Thanks for the reply Pierre. We're reaching the limits of my technical ability so it may take me some time to even try and understand what you're saying, but I will try.

I'm just wondering though, since GoDaddy is the worlds second largest hosting company I'm guessing that someone has already run into this issue with GoDaddy shared accounts and explored all the possible solutions hopefully finding one that works.

If this hasn't happened I would imagine that this issue will continue to come up as the general CMS MS install base grows.

UPDATE
A sharp programmer named David Crawford figured this out for us. We've got mod rewrites working on GoDaddy.

-casi

Re: Help! Can't get pretty URLs or modrewrite to work on GoDaddy

Posted: Wed Jan 03, 2007 6:45 pm
by Homersbrain
Hi. Would you care to share your solution, as I'm with godaddy and are having the same problem.

Cheers

Mike

Re: Help! Can't get pretty URLs or modrewrite to work on GoDaddy

Posted: Wed Jan 03, 2007 7:02 pm
by casidougal
I another developer who works with my company came up with this solution...I have no problem sharing the info but before I do I should ask his permission.  I'll shoot off an email to him now.

The solution he came up with works great except on the news module pages...we're planning on tackling that issue next.

FYI...1and1 hosting shared Linux accounts work great as an alternative. All that needs to be done there is simply switching the pretty URL switch in config.php to true and you get decent urls (albeit with no extensions) on all pages including news items.  The only downside with 1and1 (that I'm aware of) is that they limit all their MySQL accounts on their shared plans to 100MB while GoDaddy allows the MySQL database to use the entire space available on that shared hosting account.

I've not researched this to find out if it's really that big of deal or not...are the only things that count in the MySQL storage quota just text code?  I think so but I'm not 100% certain. If this is the case, then it would take a gargantuan site to use up 100MB.

GoDaddy mod rewrite solution

Posted: Wed Jan 03, 2007 7:23 pm
by casidougal
This is the solution that David Crawford came up with...keep in mind this is the version that does not affect the URLs created through the newsmodule.

config.php URL settings:

#------------
#URL Settings
#------------

#Show mod_rewrite URLs in the menu? You must enable 'use_hierarchy' for this to work for modules
$config['assume_mod_rewrite'] = true;

#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '.php';

#If you don't use mod_rewrite, then would you like to use the built-in
#pretty url mechanism?  This will not work with IIS and the {metadata} tag
#should be in all of your templates before enabling.
$config['internal_pretty_urls'] = false;

#If you're using the internal pretty url mechanism or mod_rewrite, would you like to
#show urls in their hierarchy?  (ex. http://www.mysite.com/parent/parent/childpage)
$config['use_hierarchy'] = false;

#If using none of the above options, what should we be using for the query string
#variable?  (ex. http://www.mysite.com/index.php?page=somecontent)
$config['query_var'] = 'page';


.htaccess settings:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]

NOTE: 04/15/07 - Godaddy has changed something and this is no longer working on new shared hosting accounts...although it's still working on the prior accounts with them that have already been set up.

UPDATE: Two hours later...OK it does still work. When I added the htaccess it took an hour or two before it was recognized for some reason...although I've never encountered a delay with my htaccess I've heard this complaint from others.

Re: Help! Can't get pretty URLs or modrewrite to work on GoDaddy

Posted: Wed Jan 03, 2007 9:26 pm
by Homersbrain
Thanks for the info. It's still driving me nuts though. I'm getting internal server error 500. That goes when I remove the contents of htaccess. I added the lines back in one at a time and it was the rewritebase command that was causing it so took it out. Now, it's not working again, and the htaccess file hasn't changed.  ???

I'm going to have a break for an hour...  :-\

Re: Help! Can't get pretty URLs or modrewrite to work on GoDaddy

Posted: Wed Jan 03, 2007 9:47 pm
by casidougal
I've been there. :)  I think your solution lies in configuring the .htaccess and config.php exactly as indicated.

I've run into very minor things messing this up...for example make sure you edit your .htaccess with notepad and not DreamWeaver or FrontPage and upload with FTP only using ASCII or automatic transfer mode.

Let me know if you're still having issues.

Also, if you're still having issue let me know exactly what kind of account you have with GoDaddy.

Re: Help! Can't get pretty URLs or modrewrite to work on GoDaddy

Posted: Thu Jan 04, 2007 12:33 am
by Homersbrain
I've finally got it working (fingers crossed)

I use a mac, and my text editor is Smultron. Never had any problems with it before. htaccess was being transferred in ascii mode and when I re-edited it, it looked fine.

I fired up my windows laptop and edited it, and it was just one long line. Re-formatted it and it's now working fine. I've also edited my config settings (see below) and it's all working.

Thanks for your help, and prompting me to try a different editor.

Mike

#------------
#URL Settings
#------------

#Show mod_rewrite URLs in the menu? You must enable 'use_hierarchy' for this to work for modules
$config['assume_mod_rewrite'] = true;

#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '/';

#If you don't use mod_rewrite, then would you like to use the built-in
#pretty url mechanism?  This will not work with IIS and the {metadata} tag
#should be in all of your templates before enabling.
$config['internal_pretty_urls'] = true;

#If you're using the internal pretty url mechanism or mod_rewrite, would you like to
#show urls in their hierarchy?  (ex. http://www.mysite.com/parent/parent/childpage)
$config['use_hierarchy'] = true;

Re: Help! Can't get pretty URLs or modrewrite to work on GoDaddy

Posted: Sat Feb 03, 2007 6:47 am
by WebGirl
Hi Homersbrain,
Homersbrain wrote: I've finally got it working (fingers crossed).  I use a mac (snip)


#Extension to use if you're using mod_rewrite for pretty URLs.
$config['
page_extension'] = '/';
To get the '.html' extensions working, I changed this one line of yours from the slash '/' to this:

$config['page_extension'] = '.html';

Works like a charm on all pages ... except News pages which are still coming out like this:

http://mywebsitenamedotcom/index.php?ma ... eturnid=88

Still searching for a solution to that one thing :)

[ps - I'm on a Mac too :)]

Re: Help! Can't get pretty URLs or modrewrite to work on GoDaddy

Posted: Sun Feb 04, 2007 12:03 pm
by Pierre M.
Hello,

I've read somewhere that the news module is being rewritten to have pretty URLS like this :
/news/yyyy/mm/dd/some-title-of-the-item.html

If I'm not wrong, as soon as this URL scheme will be available, the htaccess tuning will have two lines :
one for URLs begining with '/news/'
and one for the others pretty URLs like /zoo/fish/shark.html

Of course, ".html" is the page extension you choose. May be '.xhtml' or ''.
PM

Re: GoDaddy mod rewrite solution

Posted: Sun Dec 21, 2008 10:30 pm
by mannerv
casidougal wrote: UPDATE: Two hours later...OK it does still work. When I added the htaccess it took an hour or two before it was recognized for some reason...although I've never encountered a delay with my htaccess I've heard this complaint from others.
Thanks for this tip.

I found official info about this also. From GoDaddy Help Center: "Changes made to an existing .htaccess file will be seen immediately. When a new .htaccess file is created or an existing .htaccess file is deleted, however, these changes will not be seen until the htaccess cache is cleared. This occurs every hour." (http://help.godaddy.com/topic/77/article/1082)

I have no idea if this is relevant for some, but at GoDaddy "they are using a directory system like y/o/u/yournamecom/html/foo/bar". So, this might help: RewriteRule !^index\.php$  ./index.php?path=$1 [NC,L]
(http://eccegratum.blogspot.com/2007/06/ ... using.html)

Also, here is my .htaccess file for GoDaddy. This seems to work okay. The file is a bit messy, but maybe it is of help for someone. Feel free to point any mistakes I have made. It is way past midnight and I my thinking is not very clear, but for now, the file below seems to be doing the trick for me. This file is relevant for the mod_rewrite option.

EDIT: All worked out okay for a while, but now my news stopped working. I am trying to find the reason.

.htaccess

# Deny access to config.php
# This can be useful if php ever breaks or dies
# Use with caution, this may break other functions of CMSms that use a config.php
# file.  This may also break other programs you have running under your CMSms
# install that use config.php.  You may need to add another .htaccess file to those
# directories to specifically allow config.php.

order allow,deny
deny from all


# Attempt to override some php settings, these settings may be helpful on some hosts if your
# default configuration does not meet CMS's minimum requirements, and your host
# has given your account appropriate permissions
#php_value upload_max_filesize "10M"
#php_value session_save_path "tmp/cache"

#php_flag magic_quotes_gpc Off
#php_flag register_globals Off
#php_flag session.use_trans_sid Off

# (this is important, so uncomment if your host permit)
Options -Indexes
ServerSignature Off
ErrorDocument 403 /forbidden403.shtml
#
Options +FollowSymLinks
#

RewriteEngine on
#
#Sub-dir e.g: /cmsms/
RewriteBase /
#
# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]

# URL Filtering helps stop some hack attempts
#IF the URI contains a "http:"
RewriteCond %{QUERY_STRING} http\: [OR]
#OR if the URI contains a "["
RewriteCond %{QUERY_STRING} \[ [OR]
#OR if the URI contains a "]"
RewriteCond %{QUERY_STRING} \] [OR]
#OR if the URI contains a ""
RewriteCond %{QUERY_STRING} (\|%3E) [NC,OR]
#OR script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
#OR any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^.*$ - [F,L]
# END Filtering