31
reynaldo
ShortURLs 0.3 just released!
  • 2004/2/27 16:10

  • reynaldo

  • Not too shy to talk

  • Posts: 106

  • Since: 2004/2/13


After taking a deep look at some modules out there, I decided to write ShortUrls from scratch and slightly change the way it work.

I added 'dynamic' support for other modules so you don't have to wait for me to release a version of the hack supporting your favorite module. This have a lot of advantages but may also have a few drawbacks I may be unware of.

I also corrected a few errors the previous version had with comments and some images, and made it possible for the hack to work if you are running XOOPS from inside a dir.

Download it here:
http://www.wtmmail.com/XoopsShortUrls/ShortURLs_0.3_for_Xoops.zip

--------------------------------------------------------------------------------------

The way this hack now works is by converting urls like:
http://www.domain.com/modules/youfavmodule/yourfavscript.php
into
http://www.domain.com/yourfavmodule-yourfavscript.html

Arguments are also converted, so for example:
http://www.domain.com/modules/newbb/viewtopic.php?viewmode=thread&topic_id=1&forum=1&move=prev&topic_time=1077888891
becomes:
http://www.domain.com/newbb-viewtopic-viewmode-thread-topic_id-1-forum-1-move-prev-topic_time-1077888891.html

As you can see, the later is a fully indexable url. This means even your forums will get indexed!!!

As before, I tested this hack and found it perfectly working, BUT:
* If you find an error, I relay on you reporting it here so I can correct it.
* I recommend you to test your site throughfully after applying this hack to be sure everything is working.

What can you do if something is not working as expected?
- Open loadpage.php
- Set $is_debug to 1 ($is_debug = 1;). This will turn on debug functionality and will report what loadpage is trying to do.
- Refresh your site, View Source and send me what you see there, at the top, before the normal HTML begins.

How to install it?
It would be good if you read through the Readme file, but here are the quick instructions:
--------------------------------
1) Upload xoops_shorturls.php and loadpage.php into your XOOPS root dir.
2) Edit your .htaccess file and add the lines found in the .htaccess file I provided. If you are upgrading from a previous version, overwrite the lines you added by previous versions.
3) Edit mainfile.php somewhere around line 27, right before
if ( !defined("XOOPS_MAINFILE_INCLUDED") )

Add the following:
include "xoops_shorturls.php";

It's important that you edit the mainfile.php at your site, not the one you may be have in your hard disk, as they are different.
4) If your homepage is set to a module other than News, open loadpage.php and edit line #20
$defaultmodule "news";

Where it says "news" change it to your default module directory name, for example:
$defaultmodule "mydownloads";


Open your site and if it is working correctly, almost all URLs should be converted to a Search Engine frienly version.

I can't stress enough how important it is you report errors you may encounter.

Enjoy it!

32
carnuke
Re: ShortURLs 0.3 just released!
  • 2004/2/27 17:05

  • carnuke

  • Home away from home

  • Posts: 1955

  • Since: 2003/11/5


Quote:
I added 'dynamic' support for other modules so you don't have to wait for me to release a version of the hack supporting your favorite module. This have a lot of advantages but may also have a few drawbacks I may be unware of.


REALLY ??

Thanks once again Reynaldo for this useful piece of scripting. You will obviously know that there is another script converting to short URLs by kenogui. So I must thank both of you for producing these scripts.

Richard

33
Koreus
Re: ShortURLs 0.3 just released!
  • 2004/2/27 21:08

  • Koreus

  • Just popping in

  • Posts: 29

  • Since: 2003/2/9 2


Hi,

The previous problems have been solved, but I have found another one.

This URL doesn't work
http://www.mysite.com/admin-index-op-edit-storyid-XXX.html
It should open this page
http://www.mysite.com/modules/news/admin/index.php?op=edit&storyid=XXX
XXX = article number

But I have this error :
Warning: chdir(): No such file or directory (errno 2) in /home/mysite/www/loadpage.php on line 74


Another thing, now we can't put static html file anymore, It is redirect to loadpage.php

Else everything work fine !
Thx

34
JackJ
Re: ShortURLs 0.3 just released!
  • 2004/2/27 22:38

  • JackJ

  • Community Support Member

  • Posts: 747

  • Since: 2003/8/31


This is a very good hack. Same news problem here. Editing soapbox articles from admin has a similar result.

Warning: chdir(): No such file or directory (errno 2) in /mysite/loadpage.php on line 74

Warning: main(article.php): failed to open stream: No such file or directory in /mysite/loadpage.php on line 76

Warning: main(): Failed opening 'article.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /mysite/loadpage.php on line

35
aubrey
Re: ShortURLs 0.3 just released!
  • 2004/2/27 23:09

  • aubrey

  • Just popping in

  • Posts: 31

  • Since: 2004/2/1 2


This is a great hack and it works perfectly on my site except for one thing: I use the myAds module, and it appears the two are incompatible. This probably arises from the fact that the myAds module isn't up to date, but I don't know. What I would like to be able to do is disable URL rewriting for a certain module (In this case myAds), in any way possible. I think it will be something along the lines of
if (document.location == .Xoops_url./modules/myAds)
{
Do not rewrite;
}
But don't know what file to put it in or exactly what it should say.

Aubrey

36
reynaldo
Re: ShortURLs 0.3 just released!
  • 2004/2/28 3:44

  • reynaldo

  • Not too shy to talk

  • Posts: 106

  • Since: 2004/2/13


Quote:

Koreus wrote:
Another thing, now we can't put static html file anymore, It is redirect to loadpage.php


Koreus:
In order to avoid static .html files from being redirected, your .htaccess should be like this:
RewriteEngine on
RewriteCond 
%{REQUEST_FILENAME}   !-s
RewriteRule 
^.*.html loadpage.php [L]
RewriteRule ^$ loadpage.php [L]


The second line makes sure no redirection is done if the static file already exists.

Regarding the other error you are receiving, I would like to take a look at your site, as the url you provided:
http://www.mysite.com/admin-index-op-edit-storyid-XXX.html
should be rewritten to
http://www.mysite.com/modules/admin/index.php?op=edit&storyid=XXX
not the one you said

37
reynaldo
Re: ShortURLs 0.3 just released!
  • 2004/2/28 4:00

  • reynaldo

  • Not too shy to talk

  • Posts: 106

  • Since: 2004/2/13


Quote:

aubrey wrote:
This is a great hack and it works perfectly on my site except for one thing: I use the myAds module, and it appears the two are incompatible.
Aubrey


Aubrey:

What version of myAds are you using?
I'm testing it with version 2.0 and except for images, everything works ok.
I investigated the cause and I'll be providing a 'generic' fix as other modules may also have this problem. If you would like me to send you the fix before I release it, just shout

38
reynaldo
Re: ShortURLs 0.3 just released!
  • 2004/2/28 4:23

  • reynaldo

  • Not too shy to talk

  • Posts: 106

  • Since: 2004/2/13


Quote:

carnuke wrote:

Thanks once again Reynaldo for this useful piece of scripting. You will obviously know that there is another script converting to short URLs by kenogui. So I must thank both of you for producing these scripts.

Richard


Richard: (carnuke)

Thank you your kind words
I know about the other script from Kenogui and he made a wonderful job converting GoogleTap from PHPNuke to Xoops, the only reason I didn't like GoogleTap is it's limited to Apache 9 BackReferences (variables) so you can only rewrite urls which have at most 9 variables and if you *would* like to have urls like:
/newbb-viewtopic-topic_id-1-forum-1.html
then you are limited to just 3 additional variables.

That's the reason I decided to put the burden of translating variables on PHP instead of Apache even when it may be a little slower.

Also, the way GoogleTap is coded requires you to edit a lot of files and a lot of lines, making it difficult if you have to upgrade. With ShortURLs you only have to edit 1 line in mainfile.php to turn it on/off.

Unfortunately, Kenogui's hack inherited all those limitations althought he did a excellent job porting GoogleTap.

39
aubrey
Re: ShortURLs 0.3 just released!
  • 2004/2/28 4:31

  • aubrey

  • Just popping in

  • Posts: 31

  • Since: 2004/2/1 2


I also am using myAds 2.0 (the version with the english translation). You can see it on my site
Here

The page actually displays fine, but when you click a link (Such as a category or item), the address changes but the page just refreshes and leaves you on the home page.

And fix (However Temporary) Would be wonderful, as I have an avdertisement in a local newspaper advertising my classifieds.

Thanks for the speedy and helpful reply,

Aubrey

40
reynaldo
Re: ShortURLs 0.3 just released!
  • 2004/2/28 4:45

  • reynaldo

  • Not too shy to talk

  • Posts: 106

  • Since: 2004/2/13


Quote:

JackJ wrote:
This is a very good hack. Same news problem here. Editing soapbox articles from admin has a similar result.


JackJ:
Trying to reproduce your error here without any success
I see you are running XOOPS from within a dir. I will try with that next and see if I can get your error.
Thanks for reporting.


Login

Who's Online

300 user(s) are online (171 user(s) are browsing Support Forums)


Members: 0


Guests: 300


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