Page 1 of 1

url rewrites display root_path

Posted: Fri Jul 29, 2011 2:19 pm
by Jesse
I am trying to write redirects to have old urls go to new urls.
The site I am currently working on is at
http://209.97.208.212
I have a redirect set up
RewriteRule ^education-center.htm$ financial-fitness-center [R=301,L]

I would expect http://209.97.208.212/education-center.htm
to redirect as

http://209.97.208.212/financial-fitness-center

but instead it redirects as

http://209.97.208.212/home/consumer/pub ... ess-center

config.php has:
$config['root_path'] = '/home/consumer/public_html/';

which matches the extra part I don't want in my url, so how do I stop this from displaying in the url?

Re: url rewrites display root_path

Posted: Fri Jul 29, 2011 3:11 pm
by M@rtijn
Read the three lines above that line in config.php :D
#Document root as seen from the webserver. No slash at the end
#If page is requested with https use https as root url
#e.g. http://blah.com
And then change it to the right url, in this case: http://209.97.208.212

Re: url rewrites display root_path

Posted: Sun Jul 31, 2011 4:17 am
by Jesse
Thank you.
Did you mean change
$config['root_path'] = '/home/consumer/public_html/';
to
$config['root_path'] = 'http://209.97.208.212';
or to
$config['root_path'] = '/home/consumer/public_html';
without trailing slash, and
http://209.97.208.212
somewhere else?

Re: url rewrites display root_path

Posted: Sun Jul 31, 2011 10:14 am
by M@rtijn
Jesse wrote: $config['root_path'] = 'http://209.97.208.212';
;D

Re: url rewrites display root_path

Posted: Tue Aug 02, 2011 5:09 pm
by Jesse
Sorry, that seems to be incorrect.
$config['root_url'] = 'http://209.97.208.212';
$config['root_path'] = '/home/consumer/public_html/';

setting
$config['root_path'] = 'http://209.97.208.212';

produces this error:
Fatal error: Class 'CmsRoute' not found in /home/consumer/public_html/lib/classes/class.contentoperations.inc.php on line 1077

Re: url rewrites display root_path

Posted: Wed Aug 03, 2011 12:52 pm
by M@rtijn
Jesse,

I'm very sorry, I have not read your question right
I thaught you were talking about the root_url.
Reading is difficult sometimes :-[

What you could do, is run the install script again (making sure you untick the 2 options -content and tables- in step 5) as that is already in the existing database. Running the installer makes the system generate the new config.php with all correct paths.

Re: url rewrites display root_path

Posted: Wed Aug 03, 2011 5:18 pm
by Jesse
Hi, I did that (again) and it rewrote config.php, but that did not fix the problem. It wrote the same root_path and everything else as it did previously.

I don't believe root_path is incorrect.

I was wondering if it had something to do with virtual hosts in apache?

I have this set up as a virtual host, not in /usr/local/apache/htdocs but rather in /home/consumer/public_html
I was using the ip address temporarily for staging purposes while the production version of the site remains up at the domain name.
The plan is to eventually point the domain name at the new site once complete.

As an experiment, I tried chenging root_url from the ip to the domain name, and changing my local machine's etc/hosts file to resolve the domain to the ip.
unfortunately it did not fix the issue and still inserts the root_path into the url for rewrites.

Re: url rewrites display root_path

Posted: Wed Aug 03, 2011 5:28 pm
by calguy1000
The apache .htaccess stuff gets executed before anything in CMSMS. Therefore apache has no concept of your 'root_path' or 'root_url'.

If you are having problems with rewrite rules then the best bet (so that you don't have confusion, which is what this sounds like) is to generate a few simple .html files with the appropriate names (in a separate subdirectory) and test your .htaccess rules and make sure they are correct.

THEN put CMSMS back into the picture with the same .htaccess rules and keep an eye on your access and error log.

I've seen people have problems like this where the .htaccess file was the problem...

I've also seen where the problem is caused by some redirections that were done in the page/template (or by some module) of CMSMS. like the {redirect_url} tag etc. The system was doing what it was told, but the administrator didn't know/remember that he had placed some other redirections in there.

Re: url rewrites display root_path

Posted: Thu Aug 04, 2011 6:14 pm
by Jesse
I have a working static file at
http://209.97.208.212/example.html

With this in the .htaccess:
RewriteRule ^test.htm$ example.html [R=301,L]

the url
http://209.97.208.212/test.htm
redirects to
http://209.97.208.212/home/consumer/pub ... ample.html

I had previously set this up (and created the redirects) on a local xampp installation where the root was /usr/local/apache/htdocs

and moved it to a remote apache server where the root is /home/consumer/public_html and that's where I started having this problem.

Not sure what to do next.

Re: url rewrites display root_path

Posted: Thu May 10, 2012 10:00 am
by manuel
This should do the trick :)

Code: Select all

RewriteRule ^education-center.htm$ http://209.97.208.212/financial-fitness-center [R=301,L]
Greetings,
Manuel