News:

Join the Facebook Fan Page.

Main Menu

Pretty URLs

Started by SMFHacks.com Team, January 31, 2007, 10:56:43 AM

Previous topic - Next topic

bluegray

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 ;)

Dannii

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."

bluegray

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.

--- 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();

bluegray


lostinphp

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??

bluegray


        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.

lostinphp

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.....

NEMINI

is mod rewrite enabled on your server?
signatures are boring.

lostinphp

Yeah, mod rewrite is enabled too. Stumped on this one.....

lostinphp

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:

QuoteOptions +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.

Dannii

Quote from: bluegray on February 17, 2007, 09:45:14 AMMmm, 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.

QuoteThe 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.

--- 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 :)

Quote from: bluegray on February 17, 2007, 01:02:10 PMA modified google sitemap to work with pretty urls is here:
http://smf-pretty-sitemap.googlecode.com/svn/trunk/sitemap.php
Nice!

Quote from: lostinphp on February 17, 2007, 08:55:08 PMSweeeet! 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:

QuoteOptions +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."

lostinphp

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?

Dannii

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."

bluegray

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 ;)

Dannii

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."

bluegray

Quote from: eldʌkaː 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.
Links in the search pages should also be fixed.

Quote from: eldʌkaː 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 ;)
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.

--- 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.

lostinphp

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.  

Col

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.

Dannii

Quote from: lostinphp on February 18, 2007, 06:34:36 PMAlso 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?

Quote from: Col on February 18, 2007, 07:07:25 PMWhy, 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.

QuoteAlso, 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."

Col

Thanks, eldʌkaː.

Quote from: eldʌkaː on February 18, 2007, 09:27:05 PM
Quote from: Col on February 18, 2007, 07:07:25 PMWhy, 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.

Advertisement: