Camen Design Forum

Friendly url

append delete Skippy

I'm trying to turn the thread.php? message-title

Into user friendly url by adjusting mod rewrite, but with no success.

Anyone done this?

Reply RSS

Replies

append delete #1. Skippy

Well, I'm going nuts with this.. Who and where do I donate to get help? Ha

I'd think this would work:

Options +FollowSymLinks
RewriteEngine on
RewriteRule thread/file/(.*)/ thread.php?file=$1
RewriteRule thread/file/(.*) thread.php?file=$1

append delete #2. Martijn

Aren’t the RewriteRules in the default `.htaccess` file working? See: https://github.com/Kroc/NoNonsenseForum/blob/e8a996c6cd3eb97c9de8762e3aa31b3b29508f93/.htaccess#L169-L172

Are you sure you have uploaded the default `.htaccess` file that came with the forum? You should be seeing friendly URLs just like on this live version of the forum.

append delete #3. Skippy

It's always been:

Domain.com/thread.php?file=the-title

:: @Skippy added on 10 Feb ’19 · 16:24

And yes, that htaccess is in there

append delete #4. Martijn

That is really surprising!

When the default `.htaccess` is there and active NoNonsenseForum should already be generating friendly URLs and you should never see “thread.php” linked to from anywhere. [1]

The only thing I can think of is that detection of the `.htaccess` is failing. But if that is the case, your forum shouldn’t be working at all and should instead be telling you your users folder is at risk. [2] Unless you have moved the users folder to a different location already?

Can you tell me a little more about your server setup? It sounds like you have hit upon some sort of edge-case here!

[1]: https://github.com/Kroc/NoNonsenseForum/blob/e8a996c6cd3eb97c9de8762e3aa31b3b29508f93/lib/functions.php#L25-L48
[2]: https://github.com/Kroc/NoNonsenseForum/blob/e8a996c6cd3eb97c9de8762e3aa31b3b29508f93/start.php#L130-L134

append delete #5. Skibby

Just to double check, I replaced the htaccess file I have with what you linked. Same results: thread.php?test as the url. If I manually input domain.com/test, as it should be, I get a Multiple Choices error, and it suggest test.rss as the link.

My htaccess additions are:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

ErrorDocument 404 /404.html

While not edited, I replaced the functions and start files as well. Same results.

Edits I have made have been to html files.

Hosting is with 1&1, well whatever they changed there name to now. Linux Professional shared package.

append delete #6. Skippy

Running PHP 7.2

append delete #7. Skippy

Well, it's beyond me right now.

( All of this is basically in a sandbox version just trying to figure it out. Yes, I know i'm not following the rules by directly editing default.config and so on. )

I did a fresh install. The .htaccess is there, it is working and accessed. Permissions are good. I can crash everything with jibber jabber in the htaccess file. So it's reading.

New install gets the: Error: .htaccess is Missing or Disabled, or the users Folder is in an Insecure Location. -- Which is all untrue per jibber jabber.

Line 134 of the start.php comment out //require FORUM_LIB.'error_htaccess.php'; and it obviously removes the error message, and will let it run.

Make a post. Click the post. Non seo url.

Take out // on 134, and go back to error message as expected.

===

config.default.php
@define ('FORUM_USERS', 'users');
to
@define ('FORUM_USERS', '/users');

- Runs but with non seo url (as expected).

===

start.php 132

define ('HTACCESS', (bool) @$_SERVER['HTTP_HTACCESS']);
to
//define ('HTACCESS', (bool) @$_SERVER['HTTP_HTACCESS']);

- Loads index.php fine. When clicking a post calling thread.php, it then loads SEO friendly URL, but page will not load. (blank white page forever spinning load)

===

3am here I give up and getting a couple hours of sleep.

append delete #8. Martijn

Hmm. What happens if you drop the `<IfModule mod_rewrite.c>` (line 134) and matching `</IfModule>` (line 178)? I seem to vaguely recall that sometimes certain rules are available in Apache but the IfModule checks fail. May be a long shot though.

Commenting out, or just setting the `define()` for `HTACCESS` to `true`, is a good way to test things for sure. That constant is defined by an environmental variable in the `.htaccess` [1] so forcing it yourself when you know the file exists and is picked up by the server is OK.

[1]: https://github.com/Kroc/NoNonsenseForum/blob/e8a996c6cd3eb97c9de8762e3aa31b3b29508f93/.htaccess#L137-L139

append delete #9. Skippy

IfModule removed has the same impact.

I'll take a look at the other, but believe I tried that.. will append.

:: @Skippy added on 12 Feb ’19 · 07:13

Yep, nothing

append delete #10. Martijn

Do you know what version of Apache you are running? What version of mod_rewrite? Do you have all of the other Apache modules that NNF uses in its `.htaccess`? Does anything jump up in the Apache logs?

Honestly, if without the `IfModule` the rewriting doesn’t work (more specifically, lines 169 to 172 [1]) I am not sure how you are going to make friendly URLs work by writing your own `RewriteRule`s. Either Apache applies RewriteRules or it doesn’t. Though I am confused about how it would be able to apply the HTTPS rewrite if that were the case.

That said, this seems to be a real edge-case with your hosting setup.

[1]: https://github.com/Kroc/NoNonsenseForum/blob/e8a996c6cd3eb97c9de8762e3aa31b3b29508f93/.htaccess#L169-L172

append delete #11. Skippy

I'm not really sure what gives with it.. I'm inclined to think it's something with the php since I can mod_rewrite anything else on the same server and test fine. But that really doesn't make sense either.

The php files that are working to build the page and url are just the start and function files, correct?

I'll triple check everything, and I'm going to put a call into the host, as much as I don't want to do deal with them.

I'll get it figured out and then post here in case you want to add whatever is figured out in a "if you host with 1&1" section. Ha.

Thanks for the help so far.

append delete #12. Skippy

There support hasn't improved.
"
You can use the script below as the mod_rewrite

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
"

Reply

(Leave this as-is, it’s a trap!)

There is no need to “register”, just enter the same name + password of your choice every time.

Pro tip: Use markup to add links, quotes and more.

Your friendly neighbourhood moderators: Kroc, Impressed, Martijn