0

I want to know how can I convert url from

www.mydomain.com/product.php?product-full-name&product_id=123

To

www.mydomain.com/product/product-full-name/123

I know this is possible by URL rewriting in htaccess. It will great if someone show me the correct and clear way to do this. Thank you.

  • 1
    http://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess – Farkie Jun 30 '16 at 20:14
  • `RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]` – Farkie Jun 30 '16 at 20:14
  • RewriteRule ^product/?$ product.php [NC,L] , here I can remove .php the extension, So I want to know how can i get part of url –  Jun 30 '16 at 20:18
  • yes Farkie, using this i can remove only .php extension but what about other part of the url –  Jun 30 '16 at 20:22

1 Answers1

0

Try this:

UPDATED:

RewriteEngine on
RewriteRule ^product/(.*)/([0-9]+) product.php?$1&product_id=$2 [L]

If you want www.mydomain.com/product.php?pname=product-full-name&product_id=123 then,

RewriteRule ^product/(.*)/([0-9]+) product.php?pname=$1&product_id=$2 [L]
im_tsm
  • 1,965
  • 17
  • 29
  • Hi Tuhin Subhra Mandal, I tried with RewriteRule ^product/(.*) product.php?$1&product_id=$2 [L] but this showing 404 not found –  Jun 30 '16 at 20:31
  • Is mod_rewrite on? – im_tsm Jun 30 '16 at 20:33
  • Hmm its working but my page design is gone( console error : status of 404 (Not Found)) , fine I will clear it. –  Jun 30 '16 at 20:47
  • I think "?product-full-name" portion is unnecessary as it is not available in $_REQUEST. Also accept my answer if it is working for you. – im_tsm Jun 30 '16 at 20:51
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/116139/discussion-between-safu-and-tuhin-subhra-mandal). –  Jun 30 '16 at 20:53