-2

example url:

view.php?theme=1&id=5

On some blogs I see the following

view/1/5

or - view.php/1/5

I suppose once the above url is in address bar, the common way to get theme and id variable is using php explode function, but how to get this as a valid address.

If I write <a href = 'view/1/5'></a> - this is not a valid href.

Any help?

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
qadenza
  • 9,025
  • 18
  • 73
  • 126
  • 1
    Possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](https://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – Marcin Orlowski Mar 24 '19 at 18:49

1 Answers1

1

You will need to implement rewriteRule in your .htaccess file in the directory where your php files resides.

Something like

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^([a-zA-Z0-9_-]+)$ view.php?id=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ view.php?id=$1

On your php you will have something like

<a href = "view/$id'></a>

or

<a href = "/$id'></a>

Always remember to shut down apachae and restart it for it to take effect

Nancy Moore
  • 2,322
  • 2
  • 21
  • 38