Advertisement:

Author Topic: Pretty URLs  (Read 2346485 times)

Offline bluegray

  • Semi-Newbie
  • *
  • Posts: 48
Re: Pretty URLs 0.9.2
« Reply #80 on: February 16, 2007, 06:26:10 AM »
There are no errors in the log files, and I am using ISO-8859-1 character encoding as it is a standard english board.

The code to the custom sitemap is at the link I provided, it is too much to post.
Maybe you can give a quick overview of how the mod works. I also do not have time to go through your mod in detail now. Whenever you have time ;)

Offline Dannii

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 10,210
  • Mind the volcano!
    • curiousdannii on GitHub
Re: Pretty URLs 0.9.2
« Reply #81 on: February 16, 2007, 06:33:48 AM »
Changing to UTF-8 might give better results.. it's all I've tested on. I wouldn't have thought that would be a problem though, as it should convert it to unicode itself.

As to the sitemaps.. the code in it is pretty bad, but it shouldn't be too hard. You'll need to change the queries so that they get the pretty_urls column from the topics table. Ask the sitemaps creator for help, as they'll know how to do it more easily.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Offline bluegray

  • Semi-Newbie
  • *
  • Posts: 48
Re: Pretty URLs 0.9.2
« Reply #82 on: February 17, 2007, 09:45:14 AM »
Mmm, I don't think I'll be changing to UTF-8 anytime soon. Will poke around and see if I can find the problem with the extended characters. Maybe it is because the Subs-PrettyUrls.php file is in UTF-8?

The problem with my index page was that $context['pretty']['board_urls'] was not defined in SSI.php. Adding the following lines like in index.php fixed it.

Code: [Select]
--- SSI.php~    2007-02-13 22:39:19.000000000 +0200
+++ SSI.php     2007-02-17 16:15:54.000000000 +0200
@@ -79,6 +79,9 @@
 
 // Load installed 'Mods' settings.
 reloadSettings();
+$context = array('pretty' => array());
+// Unserialize the array of pretty board URLs
+$context['pretty']['board_urls'] = unserialize($modSettings['pretty_board_urls']);
 // Clean the request variables.
 cleanRequest();

Offline bluegray

  • Semi-Newbie
  • *
  • Posts: 48
Re: Pretty URLs 0.9.2
« Reply #83 on: February 17, 2007, 01:02:10 PM »
A modified google sitemap to work with pretty urls is here:
http://smf-pretty-sitemap.googlecode.com/svn/trunk/sitemap.php
 

Offline lostinphp

  • Newbie
  • *
  • Posts: 8
Re: Pretty URLs 0.9.2
« Reply #84 on: February 17, 2007, 01:28:49 PM »
I have installed everything, no errors, fixed the .htaccess file. Get "Pretty URLs" on my site, but when I click on them, get Not Found errors on the Pretty URLs. My base folder is /forum/. I uncommented the line in .htaccess file to account for this. I had this same problem when I was trying to work on a Mambo site and get the URLs looking good. Always get the Not Found error, so it must be something I am doing wrong. Any suggestions??

Offline bluegray

  • Semi-Newbie
  • *
  • Posts: 48
Re: Pretty URLs 0.9.2
« Reply #85 on: February 17, 2007, 03:56:32 PM »

        RewriteRule ^([-_a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1.0 [L,QSA]
#       To change the base url, just add the child folder name to the front of the pattern. Example:
#       RewriteRule ^/forum/([-_a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1.0 [L,QSA]

You have to add /forum/ between the ^ and ( to all the rules I think.

Offline lostinphp

  • Newbie
  • *
  • Posts: 8
Re: Pretty URLs 0.9.2
« Reply #86 on: February 17, 2007, 07:23:15 PM »
I just tried that too and still get NOT FOUND for the URLs. I know it's probably something simple I'm doing wrong. Hopefully I will figure it out soon.....

Offline NEMINI

  • SMF Hero
  • ******
  • Posts: 1,570
  • Gender: Male
Re: Pretty URLs 0.9.2
« Reply #87 on: February 17, 2007, 07:58:06 PM »
is mod rewrite enabled on your server?
signatures are boring.

Offline lostinphp

  • Newbie
  • *
  • Posts: 8
Re: Pretty URLs 0.9.2
« Reply #88 on: February 17, 2007, 08:28:55 PM »
Yeah, mod rewrite is enabled too. Stumped on this one.....

Offline lostinphp

  • Newbie
  • *
  • Posts: 8
Re: Pretty URLs 0.9.2
« Reply #89 on: February 17, 2007, 08:55:08 PM »
Sweeeet! Finally got it fixed. Here is what I was doing wrong. Number one, I was fooling with the .htaccess in the public_html folder, not the /forum/ folder. There wasn't even a .htaccess file in the /forum/ folder. Had to make one and then added this into that folder:

Quote
Options +FollowSymLinks
RewriteEngine on

#        Pretty board urls
RewriteRule ^([-_a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1.0 [L,QSA]
RewriteRule ^([-_a-zA-Z0-9]+)/([0-9]*)/?$ ./index.php?pretty;board=$1.$2 [L,QSA]

#        Pretty topic urls
RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1;topic=$2.0 [L,QSA]
RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([0-9]*)/?$ ./index.php?pretty;board=$1;topic=$2.$3 [L,QSA]
RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/msg([0-9]*)/?$ ./index.php?pretty;board=$1;topic=$2.msg$3 [L,QSA]
RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/new/?$ ./index.php?pretty;board=$1;topic=$2.new [L,QSA]

#        To change the base url, just add the child folder name to the front of the pattern. Example:
RewriteRule ^/forum/([-_a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1.0 [L,QSA]

Now everything seems to be working kosher. Thanks for the help. Hope nobody else has such a hard time with such a simple problem.

Offline Dannii

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 10,210
  • Mind the volcano!
    • curiousdannii on GitHub
Re: Pretty URLs 0.9.2
« Reply #90 on: February 17, 2007, 10:06:11 PM »
Mmm, I don't think I'll be changing to UTF-8 anytime soon. Will poke around and see if I can find the problem with the extended characters. Maybe it is because the Subs-PrettyUrls.php file is in UTF-8?
It's possible... all I can recommend is using UTF-8. I don't know how the other character encodings would work with it.

Quote
The problem with my index page was that $context['pretty']['board_urls'] was not defined in SSI.php. Adding the following lines like in index.php fixed it.

Code: [Select]
--- SSI.php~    2007-02-13 22:39:19.000000000 +0200
+++ SSI.php     2007-02-17 16:15:54.000000000 +0200
@@ -79,6 +79,9 @@
 
 // Load installed 'Mods' settings.
 reloadSettings();
+$context = array('pretty' => array());
+// Unserialize the array of pretty board URLs
+$context['pretty']['board_urls'] = unserialize($modSettings['pretty_board_urls']);
 // Clean the request variables.
 cleanRequest();
Oh, I hadn't thought of that. I'll add it myself too. Thanks :)

A modified google sitemap to work with pretty urls is here:
http://smf-pretty-sitemap.googlecode.com/svn/trunk/sitemap.php
Nice!

Sweeeet! Finally got it fixed. Here is what I was doing wrong. Number one, I was fooling with the .htaccess in the public_html folder, not the /forum/ folder. There wasn't even a .htaccess file in the /forum/ folder. Had to make one and then added this into that folder:

Quote
Options +FollowSymLinks
RewriteEngine on

#        Pretty board urls
RewriteRule ^([-_a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1.0 [L,QSA]
RewriteRule ^([-_a-zA-Z0-9]+)/([0-9]*)/?$ ./index.php?pretty;board=$1.$2 [L,QSA]

#        Pretty topic urls
RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1;topic=$2.0 [L,QSA]
RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([0-9]*)/?$ ./index.php?pretty;board=$1;topic=$2.$3 [L,QSA]
RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/msg([0-9]*)/?$ ./index.php?pretty;board=$1;topic=$2.msg$3 [L,QSA]
RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/new/?$ ./index.php?pretty;board=$1;topic=$2.new [L,QSA]

#        To change the base url, just add the child folder name to the front of the pattern. Example:
RewriteRule ^/forum/([-_a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1.0 [L,QSA]

Now everything seems to be working kosher. Thanks for the help. Hope nobody else has such a hard time with such a simple problem.
the .htaccess file should be in your forum's root directory (although it might work elsewhere too). You should probably comment out that last line. It shows what to do if you want to add a pretend base folder to your urls. I use it in my forum: http://ftgforums.com/forum/general-game/0/. There is actually no /forum/ there, SMF is located just at http://ftgforums.com/.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Offline lostinphp

  • Newbie
  • *
  • Posts: 8
Re: Pretty URLs 0.9.2
« Reply #91 on: February 18, 2007, 05:42:27 AM »
Just one thing I noticed about this Mod - When you use the jump to at the bottom of the page it takes you to the original URLs for the thread. Noticed this on your site that you posted also. Instead of directing to hxxp:ftgforums.com/forum/general-game/0/ [nonactive] where you want the URL to redirect, the jump to is taking you to hxxp:ftgforums.com/index.php?board=1.0 [nonactive] Google is noticing both URLs too as you have PR1 for one page and PR0 for the other. Maybe a fix for that? Or am I missing something?

Offline Dannii

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 10,210
  • Mind the volcano!
    • curiousdannii on GitHub
Re: Pretty URLs 0.9.2
« Reply #92 on: February 18, 2007, 05:46:33 AM »
The jumpto box isn't controlled by the Source files (the only place where I've been replacing URLs so far). I'll have to fix it later.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Offline bluegray

  • Semi-Newbie
  • *
  • Posts: 48
Re: Pretty URLs 0.9.2
« Reply #93 on: February 18, 2007, 05:47:53 AM »
Is it possible to add a robots noindex meta tag or something to all pages but the pages with pretty urls? That would maybe be easier than 301 redirects, just thinking out load here ;)

Offline Dannii

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 10,210
  • Mind the volcano!
    • curiousdannii on GitHub
Re: Pretty URLs 0.9.2
« Reply #94 on: February 18, 2007, 05:55:07 AM »
Hmm, you could do it by checking whether $_REQUEST['pretty'] is set, and adding a noindex if it isn't. I will add redirects, but it will take time ;)
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Offline bluegray

  • Semi-Newbie
  • *
  • Posts: 48
Re: Pretty URLs 0.9.2
« Reply #95 on: February 18, 2007, 11:14:07 AM »
The jumpto box isn't controlled by the Source files (the only place where I've been replacing URLs so far). I'll have to fix it later.
Links in the search pages should also be fixed.

Hmm, you could do it by checking whether $_REQUEST['pretty'] is set, and adding a noindex if it isn't. I will add redirects, but it will take time ;)
Added the following lines to Sources/Display.php. Do you think $modSettings['pretty_root_url'] is a good way to check whether pretty urls is installed or not, or is there a better way?  Anyway, look like it works.
Code: [Select]
--- Sources/Display.php.bkp     2007-02-18 17:52:08.000000000 +0200
+++ Sources/Display.php 2007-02-18 17:54:08.000000000 +0200
@@ -813,6 +813,10 @@
        // Load up the "double post" sequencing magic.
        if (!empty($options['display_quick_reply']))
                checkSubmitOnce('register');
+
+       // If it is not a pretty url, tell the robots not to index this page.
+       if (!isset($_REQUEST['pretty']) && isset($modSettings['pretty_root_url']))
+               $context['robot_no_index'] = true;
 }
 
 // Callback for the message display.
Something similar could also be added to the board and message index pages. Just a note that you have to think carefully before adding this, as this will cause bots to remove the old urls from the search index as it crawls your site, which is not a problem if you are committed to the new urls. It should prevent duplicate content though.

Offline lostinphp

  • Newbie
  • *
  • Posts: 8
Re: Pretty URLs 0.9.2
« Reply #96 on: February 18, 2007, 06:34:36 PM »
Also getting another URL for the same post on main board (over by Last post by) ending in sequence message posted eg. /test-url/msg6/#new, /test-url/msg7/#new, /test-url/msg8/#new . Just another URL to fidget with.  

Offline Col

  • Sr. Member
  • ****
  • Posts: 964
Re: Pretty URLs 0.9.2
« Reply #97 on: February 18, 2007, 07:07:25 PM »
Hi eldʌkaː,

Why, when I click an individual message, the URL displays such as this: http://dev.eldacar.com/prettyurls/general-discussion/turkce-karekter-sisgsg/msg69/#msg69

Also, what happens if two threads have the same title?

I really like the look of this mod. It will help with page rankings.

Thanks.

Offline Dannii

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 10,210
  • Mind the volcano!
    • curiousdannii on GitHub
Re: Pretty URLs 0.9.2
« Reply #98 on: February 18, 2007, 09:27:05 PM »
Also getting another URL for the same post on main board (over by Last post by) ending in sequence message posted eg. /test-url/msg6/#new, /test-url/msg7/#new, /test-url/msg8/#new . Just another URL to fidget with.
What's the problem with these?

Why, when I click an individual message, the URL displays such as this: http://dev.eldacar.com/prettyurls/general-discussion/turkce-karekter-sisgsg/msg69/#msg69
That's the same as how it is normally. The msg69/#msg69 allows you to link to a single message.

Quote
Also, what happens if two threads have the same title?
It will add the topic number to the end, like these ones:
http://dev.eldacar.com/prettyurls/general-discussion/making-two-pages-of-threads/0/
http://dev.eldacar.com/prettyurls/general-discussion/making-two-pages-of-threads-t41/0/
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Offline Col

  • Sr. Member
  • ****
  • Posts: 964
Re: Pretty URLs 0.9.2
« Reply #99 on: February 19, 2007, 06:31:04 AM »
Thanks, eldʌkaː.

Why, when I click an individual message, the URL displays such as this: http://dev.eldacar.com/prettyurls/general-discussion/turkce-karekter-sisgsg/msg69/#msg69
That's the same as how it is normally. The msg69/#msg69 allows you to link to a single message.

The bit I don't understand is the repetition of "msg69". Why do you need that twice? I understand its function, just not its form.