Jump to content

PHP and .htaccess Help


wherkamp

Recommended Posts

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=KingServerInfo
https://github.com/wherkamp/KingServerInfo
PS. I did Google it that is How I know it uses htaccess.

 

My Current Code: https://git.kingtux.me/KingTux/TuxForums

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.