-3

How do I make a site with Search Engine friendly urls? Do I need special PHP code instead of:

$_GET['id']

How to access 'id' variable after rewriting URL?

tshepang
  • 12,111
  • 21
  • 91
  • 136
user1942505
  • 480
  • 5
  • 11
  • 20
  • 3
    [What have you tried?](http://www.whathaveyoutried.com/) See [ask advice](http://stackoverflow.com/questions/ask-advice), please. FYI, there are **lots** of tutorials out there explaining how to do this *exactly*. – John Conde Feb 17 '13 at 21:28

2 Answers2

0

In your example you just need below code in your .htaccess file, in main directory.

Options +FollowSymLinks
RewriteEngine on

RewriteRule /(.*) ?id=$1

Don't forget to create your links domain.com/123456 style. Web server will resolve domain.com/123456correctly. For example:

<a href='domain.com/123456'>the link</a>

This is very basic question and there are millions of tutorials on internet. Just make some googling buddy.

aiternal
  • 1,080
  • 3
  • 16
  • 33
0

Just add this to your htaccess file

Options +FollowSymLinks
RewriteEngine on

RewriteRule /(.*) ?id=$1 [QSA,NC,L]

note: if you already have

Options +FollowSymLinks
RewriteEngine On

on your htaccess file, just place

RewriteRule /(.*) ?id=$1 [QSA,NC,L]

under it and ignore the rest

instead of visiting domain.com/?id=123456, you now visit domain.com/123456/. then on that page you can still use $_GET['id'] the way you normally would

Keezy
  • 293
  • 4
  • 15