Author Topic: The solution for Short (SEO Friendly) URL's  (Read 84011 times)

Offline Ruud

  • Posts: 3653
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: The solution for Short (SEO Friendly) URL's
« Reply #25 on: November 18, 2011, 11:42:44 PM »
Can you share the link where this is happening? (PM if you do not want to make it public)
Never mind, I found the problem.

The form module, since WB2.8.2, suddenly uses the $_SERVER['SCRIPT_NAME'] variable as the url to post the data.
The script_name is the script that is used after rewrites. This means it will use the /short.php for posting the data.
Previous versions of the form module were using $_SERVER['PHP_SELF']. That will show the original request before any rewriting.

The good solution would be to modify the form module (view.php) and modify all 'SCRIPT_NAME' into 'PHP_SELF'.

The dirty solution is to modify /short.php and add before line 40  (  require.... ) a line that says:
$_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
This will fake the correct value in the SCRIPT_NAME variable..
Note: This could break (or fix as well) other modules that make use of that variable!
 

Offline dbs

  • Betatester
  • **
  • Posts: 8147
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: The solution for Short (SEO Friendly) URL's
« Reply #26 on: November 18, 2011, 11:49:04 PM »
have taked the good solution and it works  :-)

now i see a problem with the news module. "read more" makes nothing.

Offline Ruud

  • Posts: 3653
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: The solution for Short (SEO Friendly) URL's
« Reply #27 on: November 19, 2011, 12:04:04 AM »
now i see a problem with the news module. "read more" makes nothing.
I must confess I only tested on 2.8.1, there it is working fine  (example www.dev4me.nl/nieuws/ )
I will have a look on a 2.8.2. installation later.

Offline Bug

  • Posts: 237
Re: The solution for Short (SEO Friendly) URL's
« Reply #28 on: November 19, 2011, 07:45:04 AM »
I guess the next step is a version where /posts will also be rewritten to' nieuws' (or whatever the name of the rootparent is)?

NorHei

  • Guest
Re: The solution for Short (SEO Friendly) URL's
« Reply #29 on: November 19, 2011, 09:31:48 AM »
Quote
The good solution would be to modify the form module (view.php) and modify all 'SCRIPT_NAME' into 'PHP_SELF'.
Not a good idea:
http://blog.oncode.info/2008/05/07/php_self-ist-boese-potentielles-cross-site-scripting-xss/

Sorry only german, but the code examples should be understandable.

OK, here are some english articles about the problem:
http://seancoates.com/blogs/xss-woes
http://www.mc2design.com/blog/php_self-safe-alternatives
« Last Edit: November 19, 2011, 09:40:23 AM by NorHei »

Offline dbs

  • Betatester
  • **
  • Posts: 8147
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: The solution for Short (SEO Friendly) URL's
« Reply #30 on: November 19, 2011, 09:45:10 AM »
oh my god. i must ruuds "good solution" rechange in my form-module?

Offline Ruud

  • Posts: 3653
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: The solution for Short (SEO Friendly) URL's
« Reply #31 on: November 19, 2011, 02:37:16 PM »
Quote
The good solution would be to modify the form module (view.php) and modify all 'SCRIPT_NAME' into 'PHP_SELF'.
Not a good idea:

The form module (since WB2.7) sanitises the PHP_SELF variable so it will not be affected.
Code: [Select]
htmlspecialchars(strip_tags($_SERVER['PHP_SELF']))
The better solution would be that the module would generate the current url out of the WB database. Not using any $_SERVER[] method. 

Offline Ruud

  • Posts: 3653
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: The solution for Short (SEO Friendly) URL's
« Reply #32 on: November 19, 2011, 03:21:35 PM »
I just put a new version (v2.1) on http://short.allwww.nl

This should fix both reported problems.

For redirected pages (the shortened url's) the SCRIPT_NAME variable is now changed with the value of REQUEST_URI. This was already done for the PHP_SELF variable in previous versions, because it would report the wrong url. REQUEST_URI is believed safe to use.
No modifications to the Form modules are needed by this fix.

The news module in 282 is not using defines anymore, so this is changed in the short.php script and is now working in WB282 as well as previous versions.

Offline dbs

  • Betatester
  • **
  • Posts: 8147
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: The solution for Short (SEO Friendly) URL's
« Reply #33 on: November 19, 2011, 04:48:18 PM »
Now all seems to be allright  :-)
Good script, thx ruud.

NorHei

  • Guest
Re: The solution for Short (SEO Friendly) URL's
« Reply #34 on: November 20, 2011, 07:49:46 AM »
Good Work !

Offline Sokhim Sim

  • Posts: 101
  • Gender: Male
    • Angkor Design Website
Re: The solution for Short (SEO Friendly) URL's
« Reply #35 on: November 24, 2011, 10:49:37 AM »
Good Job, I have test and use this module. But my question with this plugin why we still have old link work after we change to short URL.

Ex 1: http://www.mywebsite.com/pages/accommodations.php

Ex 2: http://www.mywebsite.com/accommodations/

It work the same link but i want to remove Ex 1. How?

Best Regards,  :-D
Freelance Website Design in Cambodia.

Clients: http://www.websitebaker2.org/forum/index.php/topic,24514.0.html

Offline Ruud

  • Posts: 3653
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: The solution for Short (SEO Friendly) URL's
« Reply #36 on: November 24, 2011, 11:31:49 AM »
Try adding this to your .htaccess

Code: [Select]
RewriteCond %{REQUEST_URI} pages
RewriteRule ^pages/(.*).php$ /$1/ [R=301,L]

It shoud replace /pages/something/more.php into /something/more/

See it in action on: http://short.allwww.nl/pages/howto/mod_rewrite.php )

Offline Sokhim Sim

  • Posts: 101
  • Gender: Male
    • Angkor Design Website
Re: The solution for Short (SEO Friendly) URL's
« Reply #37 on: November 25, 2011, 09:55:58 AM »
Thanks it working fine, now work one link something like /accommodations/happy-view-rooms/.

Happy  :-D
Freelance Website Design in Cambodia.

Clients: http://www.websitebaker2.org/forum/index.php/topic,24514.0.html

Offline iradj

  • Posts: 353
  • Gender: Male
Re: The solution for Short (SEO Friendly) URL's
« Reply #38 on: December 06, 2011, 11:40:38 AM »
Hi Ruud,

I try on a test server (2.8.1, Rev. 1285) and get "500 Internal Server Error". What am I doing wrong?

BR Iradj

Offline Ruud

  • Posts: 3653
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: The solution for Short (SEO Friendly) URL's
« Reply #39 on: December 06, 2011, 12:04:39 PM »
If you do not have any other rules in the .htaccess it could be that your server does not allow rewriting url's.
If you have other rules, you will need to experiment what is causing the conflict.

The error 500 is the error where the server says: "I don't know what, but something is wrong".
So it is very hard to tell what is wrong.

Offline iradj

  • Posts: 353
  • Gender: Male
Re: The solution for Short (SEO Friendly) URL's
« Reply #40 on: December 06, 2011, 03:23:29 PM »
I think you're right. I've just loaded on the server, the modules "download_gallery_2".
In the directory / media / download_gallery is also a ".htaccess" is created. I could not download files from this directory. After I deleted .htaccess did it again.
If the error is actually on my server?

Offline Ruud

  • Posts: 3653
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: The solution for Short (SEO Friendly) URL's
« Reply #41 on: December 06, 2011, 03:32:20 PM »
The "500 Internal Server Error" says it all.
It is a server error.

What you can or cannot do using .htaccess is depending on the server configuration.
You could try asking your hoster (by sending them the .htaccess file) if there is something in the that is not allowed.

Offline unawave2

  • Posts: 94
Re: The solution for Short (SEO Friendly) URL's
« Reply #42 on: December 07, 2011, 09:01:13 AM »
WB generates PERFECT SEF-URLs. The only issue is that URLs depend on Menu-Titles.

In the German section of this forum I wrote some modifications to bypass this restriction:






Offline dbs

  • Betatester
  • **
  • Posts: 8147
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: The solution for Short (SEO Friendly) URL's
« Reply #43 on: December 07, 2011, 09:14:57 AM »
thx for hint, havn't see it before.

Offline dbs

  • Betatester
  • **
  • Posts: 8147
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: The solution for Short (SEO Friendly) URL's
« Reply #44 on: January 27, 2012, 01:04:44 PM »
Hello,

i use short-url v2.2 together with the module 404-redirect v0.4 (http://www.websitebaker2.org/forum/index.php/topic,21145.0.html).

It seems the module 404 don't work with short-url (in WB2.8.1 and 2.8.2).
If a page was not found i will kicked to domain.de instead error-page.
Can this confirm somebody?

Have tried to change Location in short.php, but wan't work :
Code: [Select]
header('Location: '.WB_URL);
into: header('Location: '.WB_URL.'/pages/my-error.php');

Some hints are welcome.

dbs
« Last Edit: January 27, 2012, 01:08:06 PM by dbs »

Offline Ruud

  • Posts: 3653
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: The solution for Short (SEO Friendly) URL's
« Reply #45 on: January 27, 2012, 01:20:27 PM »
Try this.. It worked for me ;-)

Edit /short.php and add - after the call to get_seo_link() on line 32 - the line:
Code: [Select]
if (!$page_id) $page_id = 11;where 11 should be replaced with the page_id of your 404 page.

see http://short.allwww.nl/this/is/a/wrong/link/

Offline dbs

  • Betatester
  • **
  • Posts: 8147
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: The solution for Short (SEO Friendly) URL's
« Reply #46 on: January 27, 2012, 01:34:25 PM »
that works   :-)

must bookmark your post, thx ruud.

the redirected page contains /pages/ in the path, but it is better than redirect to start-page.

Offline Xagone

  • Posts: 482
  • Gender: Male
  • Developper
    • Xagone Inc
Re: The solution for Short (SEO Friendly) URL's
« Reply #47 on: February 24, 2012, 04:39:51 AM »
i've mod google_sitemap.php to work with short_url

and added
RewriteRule ^sitemap.xml$ google_sitemap_shor turl.php

right after
RewriteRule ^pages/(.*).php$ /$1/ [R=301,L]


so that domain.com/sitemap.xml works like a charm (and added the line:
sitemap: http://www.mydomain.com/sitemap.xml
to the robot.txt)

By the way, sometimes the htaccess needs
Options +FollowSymLinks
and
RewriteBase /
to work properly

[gelöscht durch Administrator]
Xagone Inc. (formerly VotreEspace)
http://xagone.com/

Offline dbs

  • Betatester
  • **
  • Posts: 8147
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: The solution for Short (SEO Friendly) URL's
« Reply #48 on: February 24, 2012, 07:28:58 AM »
i have no sitemap.xml.
for google-webmastertools i had submitted the url to google_sitemap.php. google says it is all right.
with your google_sitemap_shor turl.php i do the same?
nothing more is needed if i understand this right.
or i rename to google_sitemap.php.
« Last Edit: February 24, 2012, 07:36:09 AM by dbs »

Offline Xagone

  • Posts: 482
  • Gender: Male
  • Developper
    • Xagone Inc
Re: The solution for Short (SEO Friendly) URL's
« Reply #49 on: February 24, 2012, 03:23:59 PM »
google_sitemap.php is Ok, but every single url is "redirected" in the mind of google

google_sitemap_shor turl.php only provides the shorten url, so no redirections

since you submitted google_sitemap.php you should renamed it that way to not cause error on GTools
Xagone Inc. (formerly VotreEspace)
http://xagone.com/

 

postern-length