1
efrael
Help needed to change modules path
  • 2008/5/24 11:32

  • efrael

  • Just popping in

  • Posts: 9

  • Since: 2008/5/12


Hi,
I'm wondering if i can change the path and/or the name of the modules folder and of single modules.
What I need is to change the url

http://www.mysite.com/modules/ in
http://www.mysite.com/pages/

in oder to have all my modules under the /pages/ folder.
After that I would like to rename the single modules, so that i can have
http://www.mysite.com/pages/articles/ changed in
http://www.mysite.com/pages/onlinemagazine/
or
http://www.mysite.com/pages/news/ changed in
http://www.mysite.com/pages/lastvoices/

I would like to do that without re-install the modules, in order to not loose the current contnts of single modules.

Thanks

2
jimmyx
Re: Help needed to change modules path
  • 2008/5/24 11:48

  • jimmyx

  • Quite a regular

  • Posts: 338

  • Since: 2007/7/18


create a folder named pages in your server and then you can move your site to the folder and update the path in your mainfile.php

to change the name of module please read here
https://xoops.org/modules/newbb/viewtopic.php?topic_id=63780&viewmode=flat&order=ASC&type=&mode=0&start=0

3
efrael
Re: Help needed to change modules path
  • 2008/5/24 13:09

  • efrael

  • Just popping in

  • Posts: 9

  • Since: 2008/5/12


Thanks jimmyx,

I tried the first step

Quote:

jimmyx wrote:
create a folder named pages in your server and then you can move your site to the folder and update the path in your mainfile.php


I create the folder http://www.mysite.com/pages/
I moved all the /modules of my site there, but in the mainfile.php I can't find any url or path containing the /modules reference...

Something wrong?

4
trabis
Re: Help needed to change modules path
  • 2008/5/24 13:40

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Well, the above hack lets you change for example

http://www.mysite.com/modules/articles/ changed in
http://www.mysite.com/onlinemagazine/

So if you really want to have "/pages/" attached to the resulting link you will have to move your entire site to

http://www.mysite.com/pages

you would then have pages like:
http://www.mysite.com/pages/user.php
http://www.mysite.com/pages/register.php
etc...


I dont think this make any sense,eheh.
If you can have it renamed without /pages/ or /modules/ then why add this?

So my option would be to forget that first step!

5
efrael
Re: Help needed to change modules path
  • 2008/5/24 18:06

  • efrael

  • Just popping in

  • Posts: 9

  • Since: 2008/5/12


Ok I tried the hack, it's ok for me to change

http://www.mysite.com/modules/articles/ in
http://www.mysite.com/onlinemagazine/

and I don't need to have /pages/ directory in my URLs, but the hack simply don't work.

Don't know why.

I change the .htaccess this way

RewriteEngine on
RewriteRule ^linksutili/(.*)$ /modules/weblinks/$1 [L]
RewriteRule ^terapia/(.*)$ /modules/content/$1 [L]
RewriteRule ^main.css$ /xoops.css [L]
RewriteRule ^include/main.js$ /include/xoops.js [L]


I change mainfile.php this way

$GLOBALS['_rewriteRulesFrom'] = array(
'/linksutili/',
'/terapia/',
'/main.css',
'/include/main.js',
);

$GLOBALS['_rewriteRulesTo'] = array(
'/modules/weblinks/',
'/modules/content/',
'/xoops.css',
'/include/xoops.js',
);

$GLOBALS['_abs_offset'] = preg_replace('/https?:\/\/'.$_SERVER["HTTP_HOST"].'/','',XOOPS_URL);
$GLOBALS['_rewriteRulesTo1'] = preg_replace('/^(.*)$/e','"!('.XOOPS_URL.'|\"".$GLOBALS["_abs_offset"]."|\'".$GLOBALS["_abs_offset"].")".preg_quote("\1","!")."!"', $GLOBALS['_rewriteRulesTo']);
$GLOBALS['_rewriteRulesFrom1'] = preg_replace('/^(.*)$/','\\\1\1',$GLOBALS['_rewriteRulesFrom']);

function modules_changer( $s ) {
$s = preg_replace($GLOBALS['_rewriteRulesTo1'],$GLOBALS['_rewriteRulesFrom1'], $s);
for($i=0; $i $s = preg_replace( '/('.preg_quote(XOOPS_URL,'/').'|"|\')'.preg_quote($GLOBALS['_rewriteRulesTo'][$i],'/').'/' , "\\1".$GLOBALS['_rewriteRulesFrom'][$i] , $s ) ;
}
return $s;
}
if (empty($_SERVER['REDIRECT_URL']) || ($_SERVER['REDIRECT_URL'] == $_SERVER['REQUEST_URI'])) {
if (empty($_SERVER['REDIRECT_REDIRECT_STATUS'])) {
if (($_changer_url=modules_changer('"'.$_SERVER['REQUEST_URI'].'"')) != '"'.$_SERVER['REQUEST_URI'].'"') {
header('Location: ' . str_replace('"','',$_changer_url));
}
}
}
$_SERVER['REQUEST_URI'] = str_replace( $GLOBALS['_rewriteRulesFrom'],$GLOBALS['_rewriteRulesTo'], @$_SERVER['REQUEST_URI'] ) ;
$_SERVER['HTTP_REFERER'] = str_replace($GLOBALS['_rewriteRulesFrom'], $GLOBALS['_rewriteRulesTo'], @$_SERVER['HTTP_REFERER'] ) ;
etc. etc. etc.


Could be a problem with the modules I'm using?
Although I made this change, nothing happens.

Any idea?

6
trabis
Re: Help needed to change modules path
  • 2008/5/25 3:39

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


After that comes the most important line:

ob_start( 'modules_changer' ) ;

Do you have it?

7
trabis
Re: Help needed to change modules path
  • 2008/5/25 3:41

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


And you have an extra coma in your arrays
$GLOBALS['_rewriteRulesTo'] = array(
'/modules/weblinks/',
'/modules/content/',
'/xoops.css',
'/include/xoops.js',
);


should be:
$GLOBALS['_rewriteRulesTo'] = array(
'/modules/weblinks/',
'/modules/content/',
'/xoops.css',
'/include/xoops.js'
);


The other array as the same problem.

8
efrael
Re: Help needed to change modules path
  • 2008/5/25 10:01

  • efrael

  • Just popping in

  • Posts: 9

  • Since: 2008/5/12


Thanks a lot trabis.

I modified the mainfile.php the way you suggested, removing the extra commas from the arrays and yes, I had the

ob_start( 'modules_changer' ) ;

line


Now the mainfile is exactly in this way but it still doesn't work.

$GLOBALS['_rewriteRulesFrom'] = array(
'/linksutili/',
'/terapia/',
'/main.css',
'/include/main.js'
);

$GLOBALS['_rewriteRulesTo'] = array(
'/modules/weblinks/',
'/modules/content/',
'/xoops.css',
'/include/xoops.js'
);

$GLOBALS['_abs_offset'] = preg_replace('/https?:\/\/'.$_SERVER["HTTP_HOST"].'/','',XOOPS_URL);
$GLOBALS['_rewriteRulesTo1'] = preg_replace('/^(.*)$/e','"!('.XOOPS_URL.'|\"".$GLOBALS["_abs_offset"]."|\'".$GLOBALS["_abs_offset"].")".preg_quote("\1","!")."!"', $GLOBALS['_rewriteRulesTo']);
$GLOBALS['_rewriteRulesFrom1'] = preg_replace('/^(.*)$/','\\\1\1',$GLOBALS['_rewriteRulesFrom']);

function modules_changer( $s ) {
$s = preg_replace($GLOBALS['_rewriteRulesTo1'],$GLOBALS['_rewriteRulesFrom1'], $s);
for($i=0; $i $s = preg_replace( '/('.preg_quote(XOOPS_URL,'/').'|"|\')'.preg_quote($GLOBALS['_rewriteRulesTo'][$i],'/').'/' , "\\1".$GLOBALS['_rewriteRulesFrom'][$i] , $s ) ;
}
return $s;
}
if (empty($_SERVER['REDIRECT_URL']) || ($_SERVER['REDIRECT_URL'] == $_SERVER['REQUEST_URI'])) {
if (empty($_SERVER['REDIRECT_REDIRECT_STATUS'])) {
if (($_changer_url=modules_changer('"'.$_SERVER['REQUEST_URI'].'"')) != '"'.$_SERVER['REQUEST_URI'].'"') {
header('Location: ' . str_replace('"','',$_changer_url));
}
}
}
$_SERVER['REQUEST_URI'] = str_replace( $GLOBALS['_rewriteRulesFrom'],$GLOBALS['_rewriteRulesTo'], @$_SERVER['REQUEST_URI'] ) ;
$_SERVER['HTTP_REFERER'] = str_replace($GLOBALS['_rewriteRulesFrom'], $GLOBALS['_rewriteRulesTo'], @$_SERVER['HTTP_REFERER'] ) ;

ob_start( 'modules_changer' ) ;
// $Id: mainfile.dist.php 506 2006-05-26 23:10:37Z skalpa $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <https://xoops.org/> //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //




if ( !defined("XOOPS_MAINFILE_INCLUDED") ) {
define("XOOPS_MAINFILE_INCLUDED",1);

// XOOPS Physical Path
// Physical path to your main XOOPS directory WITHOUT trailing slash

etc, etc, these are the first 70 lines.

Other ideas?

9
trabis
Re: Help needed to change modules path
  • 2008/5/25 11:36

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Do your server have mod_rewrite on?
If nothing happens with that .htaccess then probably it does not.
Add some dummy text in that .htaccess and see if you get an server error.

10
efrael
Re: Help needed to change modules path
  • 2008/5/25 17:58

  • efrael

  • Just popping in

  • Posts: 9

  • Since: 2008/5/12


Hi trabis,

thanks again for your help.

I tested the mod_rewrite with this tool in the same directory where XOOPS is installed

http://www.wallpaperama.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html

You can directly test it on my website here

http://www.cipog.com/centrogestalt/rewrite.php

It works, so the problem must be elsewhere...

Login

Who's Online

203 user(s) are online (104 user(s) are browsing Support Forums)


Members: 0


Guests: 203


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits