0

I know it's very possible to have www.website.com/stuff/2 instead of www.website.com/stuff/page?=2 for page 2 of "stuff". How would I go about doing that though? I do not know what to search for.

Edit to say that I am using PHP and $_GET to get the parameters. This is so widely used so I didn't think it would be very difficult.

3 Answers3

2

There are 3 common ways:

  1. Rewrite the URL internally from .../2 to .../?page=2.

  2. Use the "path info" mechanism of your web language. A script at /stuff/index.xyz would have a path info of 2 with the given URL.

  3. Have the web program capture all URLs and use routing to determine which function to call and what values to pass it.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
1

It all depends on what you're using.

PHP ? I believe you're looking for apache .htaccess URL Rewriting

Ven
  • 19,015
  • 2
  • 41
  • 61
0

Yes it is very much possible with a simple mod_rewrite rule in your .htaccess. Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(stuff)/([^/]+)/?$ /$1.php?page=$2 [L,QSA,NC]
anubhava
  • 761,203
  • 64
  • 569
  • 643