News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Pretty URLs

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

Previous topic - Next topic

dougiefresh

Quote from: Fisch.666 on January 07, 2016, 08:38:56 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!

Fisch.666

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?

Kortal

Is there any way to force a total refresh of urls ? or to manually edit some ?

vbgamer45

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

AllMassive

Quote from: AllMassive on December 27, 2015, 07:45:01 PM

Quote from: MESWEB on December 27, 2015, 02:49:16 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:

Redirect permanent / https://your-forum.url/

Just tested on another install - apparently i was wrong -  its posssible to add this redirect into the .htaccess.

MESWEB

Quote from: AllMassive on January 09, 2016, 07:29:06 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?

Fisch.666

Hi,

just digged into this:

Quote from: Fisch.666 on January 08, 2016, 10:30:49 AM
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.

Kortal

Quote from: vbgamer45 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.
Allright, I'll edit the database then, thanks for your answer !

AllMassive

Quote from: MESWEB on January 09, 2016, 08:02:15 PM
Quote from: AllMassive on January 09, 2016, 07:29:06 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

Redirect permanent / https://your-forum.url/

Fisch.666

Quote from: Fisch.666 on January 09, 2016, 08:41:13 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:

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


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


Add after:


                        if($board == 0) {
                                header('HTTP/1.1 404 Not Found');
                                die;
                        }


Maybe not the best solution but works for me.

MESWEB

Quote from: AllMassive on January 09, 2016, 09:49:02 PM
Put a single line into your .htaccess

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.

Jade Elizabeth

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 career: Color With Jade/Patreon.

vbgamer45

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

Jade Elizabeth

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 career: Color With Jade/Patreon.


Kindred

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.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Jade Elizabeth

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 career: Color With Jade/Patreon.

Kindred

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.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Jade Elizabeth

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 career: Color With Jade/Patreon.

Gryzor

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:

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


with

$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!

Advertisement: