-1

How to change URL in core PHP? Please let me know how to do this

http://localhost/files/rajfireworks/product_details?pro_id=2

to

http://localhost/files/rajfireworks/product_details/productname
dur
  • 15,689
  • 25
  • 79
  • 125
  • 1
    try with .htaccess http://stackoverflow.com/questions/11899769/sef-url-without-name-with-core-php-and-htaccess – Deepak saini Apr 03 '17 at 11:46
  • 1
    Possible duplicate of [Apache rewrite - clean URLs in localhost](http://stackoverflow.com/questions/19211824/apache-rewrite-clean-urls-in-localhost) – Dez Apr 03 '17 at 11:47

4 Answers4

1

This can help you:

Write below code in your .htaccess file.

For inner page write: RewriteRule ^products/([^/]+) product_details.php?name=$1 [NC]

For all product page: RewriteRule ^products products.php [NC]

Crazy4Php
  • 246
  • 1
  • 5
0

This can help:

<?php
if(!empty($_GET['pro_id'])) {
  header("Location: /files/rajfireworks/product_details/productname");
}    
?>

Depends on product_id number - you can extend your conditions.

janfitz
  • 1,183
  • 12
  • 21
0

You can Use URL rewrite in htaccess File.

Put .htaccess file in main folder and use below code.It will read like if your URL http://example.com/index.php?page=search it will show like this http://example.com/search

Code:

RewriteEngine on
RewriteCond %{THE_REQUEST} /product\.php\?cat=(search)
RewriteRule ^ /%1? [R=302,L]
RewriteRule ^(search)$ /product.php?page=$1 [L,QSA]
Sankar V
  • 33
  • 3
0

Add the following to your .htaccess:--

RewriteEngine On

RewriteRule ^blog/([^/]*)\.html$ /test/test.php?pagetitle=$1 [L]