Advertisement:

Author Topic: Pretty URLs  (Read 2160335 times)

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,437
    • XPtsp.com Community
Re: Pretty URLs
« Reply #7380 on: January 08, 2016, 09:57:51 AM »
Does anyone has any insight how this rewrite can be improved so only valid requests get the redirect? Thanks in advance for a reply.
I'm pretty sure that if the file ACTUALLY exists at that URL, then the file is pulled instead of the URL being translated.  Otherwise, the themes wouldn't be able to be loaded so the forum could be seen....

But what I think you are asking is this: "Can the rewrite be rewritten to only redirect to valid topics/boards/messages/etc?"  My question to you would "How is the .htaccess file supposed to ascertain this without access to the database?"  The Apache .htaccess doesn't have access to the database at all, and all "translation" of the Pretty-fied URL is handled within the source files.  So any "improvement" to the handling would have to happen there, not within .htaccess.....

Hope this helps!
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline Fisch.666

  • Jr. Member
  • **
  • Posts: 204
Re: Pretty URLs
« Reply #7381 on: January 08, 2016, 10:30:49 AM »
Hey, thats absolutely true. The .htaccess itself also can't know that:

http://example.com/forum/news

should be rewritten to:

http://example.com/forum/index.php?board=2.0

so the issue is then probably more somewhere in the files the converter package is providing?

Offline Kortal

  • Semi-Newbie
  • *
  • Posts: 11
Re: Pretty URLs
« Reply #7382 on: January 09, 2016, 06:46:16 PM »
Is there any way to force a total refresh of urls ? or to manually edit some ?

Online vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,361
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Pretty URLs
« Reply #7383 on: January 09, 2016, 06:54:38 PM »
Only in the database can you manually edit them.
Board urls can be edited in admin area.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline AllMassive

  • Jr. Member
  • **
  • Posts: 133
  • Gender: Male
Re: Pretty URLs
« Reply #7384 on: January 09, 2016, 07:29:06 PM »

Yes i know and I'm update this value in db. But when I type my url like http://domain.com then I don't be redirect to https://domain.com
You need access to the apache-config for your domain port 80 virtual domain - you need:
Code: [Select]
Redirect permanent / https://your-forum.url/
Just tested on another install - apparently i was wrong -  its posssible to add this redirect into the .htaccess.

Offline MESWEB

  • Full Member
  • ***
  • Posts: 410
  • Gender: Male
    • Don't let errors.win
Re: Pretty URLs
« Reply #7385 on: January 09, 2016, 08:02:15 PM »
Just tested on another install - apparently i was wrong -  its posssible to add this redirect into the .htaccess.
So how .htaccess rewrite rule should like?

Offline Fisch.666

  • Jr. Member
  • **
  • Posts: 204
Re: Pretty URLs
« Reply #7386 on: January 09, 2016, 08:41:13 PM »
Hi,

just digged into this:

so the issue is then probably more somewhere in the files the converter package is providing?

The redirect is done within the Sources/MessageIndex.php part ( //      301 redirects) that gets edited by the prettyurls-reverter-1-0RC2 package.

Currently i can't find the place where the decision is done that board exists and should be redirected within the MessageIndex.php and where only a 200 should be thrown. Any hints / pointers are welcome.

Offline Kortal

  • Semi-Newbie
  • *
  • Posts: 11
Re: Pretty URLs
« Reply #7387 on: January 09, 2016, 08:48:49 PM »
Only in the database can you manually edit them.
Board urls can be edited in admin area.
Allright, I'll edit the database then, thanks for your answer !

Offline AllMassive

  • Jr. Member
  • **
  • Posts: 133
  • Gender: Male
Re: Pretty URLs
« Reply #7388 on: January 09, 2016, 09:49:02 PM »
Just tested on another install - apparently i was wrong -  its posssible to add this redirect into the .htaccess.
So how .htaccess rewrite rule should like?

Put a single line into your .htaccess
Code: [Select]
Redirect permanent / https://your-forum.url/

Offline Fisch.666

  • Jr. Member
  • **
  • Posts: 204
Re: Pretty URLs
« Reply #7389 on: January 10, 2016, 01:55:38 PM »
The redirect is done within the Sources/MessageIndex.php part ( //      301 redirects) that gets edited by the prettyurls-reverter-1-0RC2 package.

Currently i can't find the place where the decision is done that board exists and should be redirected within the MessageIndex.php and where only a 200 should be thrown. Any hints / pointers are welcome.

Ok, put some time into that and found the solution. The decision is done within the Sources/QueryString.php part which gets added by the prettyurls-reverter-1-0RC2:

Code: [Select]
$board = (int) isset($pretty_board_lookup[$_REQUEST['board']]) ? $pretty_board_lookup[$_REQUEST['board']] : 0;
If the $pretty_board_lookup isn't successful an boardid of 0 is assumed causing the 200 to the index of the board. As i don't want to have a 200 for each request this can be easily fixed:

Open Sources/QueryString.php

Search:

Code: [Select]
                        $board = (int) isset($pretty_board_lookup[$_REQUEST['board']]) ? $pretty_board_lookup[$_REQUEST['board']] : 0;

Add after:

Code: [Select]
                        if($board == 0) {
                                header('HTTP/1.1 404 Not Found');
                                die;
                        }

Maybe not the best solution but works for me.

Offline MESWEB

  • Full Member
  • ***
  • Posts: 410
  • Gender: Male
    • Don't let errors.win
Re: Pretty URLs
« Reply #7390 on: January 10, 2016, 02:13:30 PM »
Put a single line into your .htaccess
Code: [Select]
Redirect permanent / https://your-forum.url/
This is wrong rule, but I found new rule and I put inside. So now I wait and see what happens. Many thanks for helping me.

Offline Jade Elizabeth

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,629
  • Gender: Female
  • Keep your enemies close and your friends closer ;)
    • jadetrainor on LinkedIn
    • @alundra on Twitter
    • Jades-World
Re: Pretty URLs
« Reply #7391 on: January 11, 2016, 04:09:27 AM »
Has there been any sort of progress towards compatibility with custom actions mod? :)

Or is there something I can add to htaccess for my custom action "store"? :)
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring forum: Color Me Forum/Patreon.

Online vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,361
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Pretty URLs
« Reply #7392 on: January 11, 2016, 09:16:45 AM »
No progress with custom actions not planned at this time
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline Jade Elizabeth

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,629
  • Gender: Female
  • Keep your enemies close and your friends closer ;)
    • jadetrainor on LinkedIn
    • @alundra on Twitter
    • Jades-World
Re: Pretty URLs
« Reply #7393 on: January 12, 2016, 10:59:01 PM »
I have a couple of actions that aren't working including "store" and "recenttopics" (from the ajax recent topics mod). Is there a way I can add them manually? :)
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring forum: Color Me Forum/Patreon.

Offline vietravel247.com

  • Semi-Newbie
  • *
  • Posts: 66
  • Gender: Male
  • Chao mung ban den voi hoidulich.com
    • http://facebook.com/hoidulich on Facebook
    • @vietravel247 on Twitter
    • Hội du lịch Việt Nam

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,120
  • Gender: Male
    • Kindred-999 on GitHub
Re: Pretty URLs
« Reply #7395 on: February 03, 2016, 12:31:16 PM »
why?


The #msg... is an anchor link.  So, you can't remove that without affecting where the link goes on the page...

and topicseen is an argument that is needed for the database.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Jade Elizabeth

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,629
  • Gender: Female
  • Keep your enemies close and your friends closer ;)
    • jadetrainor on LinkedIn
    • @alundra on Twitter
    • Jades-World
Re: Pretty URLs
« Reply #7396 on: February 03, 2016, 10:41:28 PM »
It would be good to remove them from the URL so you can do things like pinterest pins from your browser, people linking can not have that crap in there....we just want the canonical there really!....after it's already loaded it. I would go for that too because it's a huge hiccup for me.
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring forum: Color Me Forum/Patreon.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,120
  • Gender: Male
    • Kindred-999 on GitHub
Re: Pretty URLs
« Reply #7397 on: February 04, 2016, 08:08:23 AM »
but it HAS TO BE in the URL, if you want to use the anchor....
If you take it out, the link will just go to the top of the page.
That anchor link is only used when linking to a SPECIFIC message in a thread.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Jade Elizabeth

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,629
  • Gender: Female
  • Keep your enemies close and your friends closer ;)
    • jadetrainor on LinkedIn
    • @alundra on Twitter
    • Jades-World
Re: Pretty URLs
« Reply #7398 on: February 04, 2016, 06:19:50 PM »
I understand that, but why can it change ?topic=123 into topictitle but not ?topic=123.msg115173;topicseen#new into topictitle?

Even if it starts as that and then the url updates or something? Why can't it send where it's going through post/get and that can anchor it?

I'm not meaning when linking to specific messages like this, talking about the new post thing when coming in from unread (or the new icon in general) :):
http://www.simplemachines.org/community/index.php?topic=146969.msg3859042#msg3859042
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring forum: Color Me Forum/Patreon.

Offline Gryzor

  • Sr. Member
  • ****
  • Posts: 723
  • Gender: Male
  • CPCwiki.eu - The Amstrad CPC Encyclopaedia!
    • CPCWiki
Re: Pretty URLs
« Reply #7399 on: February 17, 2016, 05:34:48 AM »
Hello everyone!

I' want to update my aging 2.0.6. When I try to install 2.0.7, I get a warning about an edit to News.php:

Replace:
Code: [Select]
$val = preg_replace('/^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$/e', '\'\' . $scripturl . \'/\' . strtr(\'$1\', \'&;=\', \'//,\') . \'.html$2\'', $val);
return $val;

with
Code: [Select]
$val = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$~', create_function('$m', 'global $scripturl; return $scripturl . \'/\' . strtr("$m[1]", \'&;=\', \'//,\') . \'.html\' . (isset($m[2]) ? $m[2] : "");'), $val);
return $val;

Now, of course, the warning kicks in because that sections has been changed, as far as I can see, by PrettyURLs, and the whole original section has been commented out.

Any advice as to how to proceed?

Thanks!