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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.