「stuff」のページ 2 に www.website.com/stuff/page?=2 の代わりに www.website.com/stuff/2 を使用する可能性が非常に高いことはわかっています。しかし、どうすればそれを行うことができますか?何を検索すればよいかわかりません。
パラメータを取得するために PHP と $_GET を使用していると編集してください。これは非常に広く使われているので、それほど難しいとは思いませんでした。
There are 3 common ways:
Rewrite the URL internally from .../2
to .../?page=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.
Have the web program capture all URLs and use routing to determine which function to call and what values to pass it.
それはすべて、使用しているものに依存します。
PHP ? apache .htaccess URL Rewritingを探していると思います
はい、.htaccess で単純な mod_rewrite ルールを使用することで、ほとんどの場合可能です。mod_rewrite と .htaccess を有効にしてからhttpd.conf
、このコードをディレクトリの.htaccess
下に配置します。DOCUMENT_ROOT
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]