wherkamp Posted February 20, 2018 Share Posted February 20, 2018 I am wonder how this is done.Lets say I am viewing this page https://www.spigotmc.org/threads/server-wont-boot.304556/How do they know they are at page server-wont-boot.NUMBER/without doing this ?Variable_Name=server-wont-boot.NUMBER/Or using POST and having it hidden. I know it has something to do with the .htaccess file however could you tell me how and how it works. Another Example They have wherkamp/KingServerInfo which I might think it would be ?author=wherkamp&repo=KingServerInfohttps://github.com/wherkamp/KingServerInfoPS. I did Google it that is How I know it uses htaccess. My Current Code: https://git.kingtux.me/KingTux/TuxForums Quote Link to comment Share on other sites More sharing options...
requinix Posted February 21, 2018 Share Posted February 21, 2018 There are various methods depending on the server but collectively they're all called "URL rewriting". Google that. The one you're thinking of uses Apache's mod_rewrite. In essence you tell Apache that it should run a series of tests against the URL for every request, and depending on what you say it can rewrite the URL into another form. For example, # enable url rewriting with mod_rewrite RewriteEngine on # the url requested must not correspond to an actual file RewriteCond %{REQUEST_FILENAME} !-f # it can't be an actual directory either RewriteCond %{REQUEST_FILENAME} !-d # rewrite urls of the pattern /threads/something.number/ to /thread.php?id=number # then stop processing other rules RewriteRule ^threads/.*\.(\d+)/$ thread.php?id=$1 [L]Then there's a thread.php that uses $_GET[id] to display the thread. Most mod_rewrite URL rewriting schemes look basically like that. Quote Link to comment Share on other sites More sharing options...
phpmillion Posted February 21, 2018 Share Posted February 21, 2018 (edited) They use mod_rewrite. I see requinix explained it with more details and posted his explanation a second before my post, so you should really be able to get it done now. Edited February 21, 2018 by phpmillion Quote Link to comment Share on other sites More sharing options...
dalecosp Posted February 26, 2018 Share Posted February 26, 2018 It can also be done without using mod_rewrite, instead configuring Apache to serve PHP via a FORCETYPE directive and parsing the URI request, but for most of these situations mod_rewrite is probably simpler and potentially safer. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.