質問

Dynamic URL : http://sample.com/articles.php?id=1&name=abc

Static URL : http://sample.com/article/

I need the id and name in the static URL hidden.

I tried with the below code in htaccess

RewriteCond %{QUERY_STRING} ^id=(.*)&name=(.*)$

RewriteRule ^articles\.php$ /article/%1/%2? [R=301]

RewriteRule ^article/([^-]+)/([^-]+)$ /articles.php?article_id=$1&article_name=$2 [L]

But in the code i have to use %1 and %2 to get the id and name.

Is there any way to get those values without /%1/%2

Thank you in Advance.

役に立ちましたか?

解決

To get the id and name parameters without them being part in the URL:

  1. Have the user send the values by POST, instead of GET (i.e., they select the values in a form and submit it). Then the values are sent as part of the request body, not the URL.

  2. Run the site on HTTPS, so no one can observe the request body as it's being sent.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top