|
New example satsig board index with no number |
I have converted all my dynamic URLs to static URLs. The old ones were in my YaBB forum, now closed.
The dynamic URLs had a ? and a query string after that. I wanted new simple static ones, with .htm at the end.
I've learned all this for the first time, during the past two weeks so there may be mistakes. If you can add correction, clarification or comments to be added to this page please send me an email eric@satsig.net Thanks.
I want to RewriteRule them like this::
Old: https://www.satsig.net/cgi-bin/yabb/YaBB.pl?board=ivsat-us/200 (note
the forward / and number)
New:
https://www.satsig.net/topics/board=ivsat-us-200.htm
Old: https://www.satsig.net/cgi-bin/yabb/YaBB.pl?board=OneWeb (note no
forward / and no number)
New: https://www.satsig.net/topics/board=OneWeb.htm
Old: https://www.satsig.net/cgi-bin/yabb/YaBB.pl?num=1234567890
(note always 10 digits)
new: https://www.satsig.net/topics/satsig-topic-num=1234567890.htm
Old: https://www.satsig.net/cgi-bin/yabb/YaBB.pl
New:
https://www.satsig.net/topics/satsig-topics-index.htm
Regarding ReWrite condition. This defines a pattern to be matched and allows
for the capture of parts of the pattern into back references.
Pairs of two round brackets () cause parts of the matched string to be saved as a 'back
reference' so it can be used later on the next line.
The names of these back references is %1 %2 %3 etc.
If it matches, the RewriteCond condition is met. Then the next line RewriteRule starts to work.
RewriteCond %{QUERY_STRING} ^(board=[a-zA-Z0-9-]*)(/)([0-9]*)(.*)$
RewriteRule (.*) https://www.satsig.net/topics/%1-%3.htm? [R=301,L]
This is the most complicated to process with text and trailing numbers like point/400, transponder/200, ivsat-us/100
I'm using three sets of round brackets in the RewriteCond and each ( %1, %2 and %3 ) is used to store a 'back reference'.
The first one %1 stores the the word 'board=' plus the board name like OneWeb, ivsat-asia, transponder, 802, linkstar, ivsat-us, point, transponder etc
The second one %2 stores just the forward / character (which is not used further).
The third %3 stores the trailing number 100, 200, 400, 200, 1000 etc
The RewriteRule builds the output. The text https://www.satsig.net/topics/ comes first. Then %1 which stores text like "board=ivsat-asia" is added. %2 which has captured the "/" is not used. A hyphen is then inserted and finally %3 which holds the 10 digit number is added at the end
The final (.*) in the RewirteCond deals with rubbish that might follow.
The first (.*) in the ReWriteRule simply refers to the original old URL as a whole which will be replaced by the new created URL which comes after the space character.
RewriteCond %{QUERY_STRING} ^(board=[a-zA-Z0-9-]*)(.*)$
RewriteRule (.*) https://www.satsig.net/topics/%1.htm? [R=301,L]
This deals with the cases where the board name is simply some text (letters lower case, letters upper case, numbers and -) but without any forwards / and trailing numbers. Example texts are: OneWeb, ivsat-asia, transponder, 802, Any1
In this case the RewriteCond QUERY_STRING pattern for matching is between the ^ and $. It works like this.
The text "board=" is simply the first part text string to be matched. That is followed matching to letters a-z A-Z and numbers 0-9 and hyphen. The * means none or more than none. That lot is captured by the first pair of () into back reference %1. The final (.*)catches all rubbish that might follow into %2. So %1 looks like
Note all topics are of the form https://www.satsig.net/cgi-bin/yabb/YaBB.pl?num=1234567890
RewriteCond %{QUERY_STRING} ^(num=)([0-9]{10})).*$
RewriteRule (.*) https://www.satsig.net/topics/satsig-topic-num=%2.htm? [R=301,L]
The RewriteCond extracts the QUERY_STRING from the incoming URL. The
QUERY_STRING is then compared, for possible match, with whatever is between the
^ and the $ characters. ^ Start matching at this point.
$ End point of the match.
num= are the first 4 characters of the comparison. The [0-9] means it is looking
for numbers only, the 10 means exactly 10 of them.
The expression num=[0-9]{10} means look for exactly 10 number characters.
So for each pair of ()
%1 has captured 'num=' which is not used. I have put it manually into the
first part of the output: https://www.satsig.net/topics/satsig-topic-num=
%2 has captured the 10 digit number '1234567890'
RewriteRule then joins https://www.satsig.net/topics/satsig-topic-num to the 10 digit number and adds .htm at the end.
Redirect permanent /cgi-bin/yabb/YaBB.pl https://www.satsig.net/topics/satsig-topics-index.htm
In the Apache httpd.conf I added:
#10 july 2026
RewriteEngine on
RewriteCond %{QUERY_STRING} ^(board=[a-zA-Z0-9-]*)(/)([0-9]*)(.*)$
RewriteRule (.*) https://www.satsig.net/topics/%1-%3.htm? [R=301,L]
RewriteCond %{QUERY_STRING} ^(board=[a-zA-Z0-9-]*)(.*)$
RewriteRule (.*) https://www.satsig.net/topics/%1.htm? [R=301,L]
RewriteCond %{QUERY_STRING} ^(num=)([0-9]{10}).*$
RewriteRule (.*) https://www.satsig.net/topics/satsig-topic-num=%2.htm?
[R=301,L]
Redirect permanent /cgi-bin/yabb/YaBB.pl https://www.satsig.net/topics/satsig-topics-index.htm
It seems to be working !
|
► Page created 9 July 2026, amended 19 July 2026. |