Hi jemz,
Thank you for correcting your first post (trailing /) as that has a major impact on the mod_rewrite code.
As for SitePoint’s code, it’s changed during my membership period every time SitePoint has changed the forum software. Currently, I like their t/need-help-for-my-url and but understand that the following /106763/3 denotes the ID of the thread and the number of the post within the thread. Those make it easier for the forum software to ignore the thread’s title (need help for my url) and, thus, eliminates the possibility of duplicate title entries (something I had to caution my client and enforce with code and a database “unique” specification on the title field). Please view http://wilderness-wally.com to see the links just using the article titles as links (modified to remove spaces and allow LIMITED punctuation - all that is allowed in a URI) simply because the titles are more descriptive and memorable for his website visitors.
As for your code, I must assume that it’s in the DocumentRoot (mysite; because you link internally to mysite/admin/). If that’s the case, using the start anchor and no / in the RewriteRule’s regex will prevent your code from working.
For simplicity, I’d move your mod_rewrite code to the admin directory and remove the mysite/admin from the redirection. Also, your regex needs to match your URI (for the admin directory) so the regex must match view/8 and that certainly cannot be done with letters and underscores.
Leaving the mod_rewrite in the DocumentRoot (localhost), your code should simply be:
RewriteEngine on
RewriteRule ^mysite/admin/view/(\d+)$ mysite/admin/view.php?id=$1 [L]
…would do exactly what you’ve asked for (the \d+ is shorthand for one or more digits).
To do something like SitePoint’s URIs (mysite/admin/view/{garbage_characters}/{digits}), use
RewriteEngine on
RewriteRule ^mysite/admin/view/[^/]+/(\d+)$ mysite/admin/view.php?id=$1 [L]
… where the {garbage_characters} would be discarded.
To do something like http://wilderness-wally.com (using the unique title field from the database for the link), use:
RewriteEngine on
RewriteRule ^mysite/admin/([-a-zA-Z0-9_&'!\…]+)$ mysite/admin/view.php?id=$1 [L]
… where ([-a-zA-Z0-9_&'!\…]+) includes all letters, digits and ALLOWED ASCII punctuation.
Finally, WHY would you “link” to the view.php script using JavaScript (my understanding of this window.location.href directive is that it MUST be used before any output to the browser)? I use PHP to create my <a href=…>Link info</a> links within a script and populate the href value with my preferred link format, i.e., the title with spaces replaced by _'s and illegal characters removed rather than id=123456.
Whew! This is a long reply with a LOT of information (and options) so I hope I didn’t overwhelm you.
Regards,
DK