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?
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?
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
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.
It's always been:
Domain.com/thread.php?file=the-title
And yes, that htaccess is in there
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
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.
Running PHP 7.2
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.
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.
IfModule removed has the same impact.
I'll take a look at the other, but believe I tried that.. will append.
Yep, nothing
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.
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.
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
"
Your friendly neighbourhood moderators: Kroc, Impressed, Martijn