0

I'm just wondering how other websites replace there get variable.

example: http://www.example.com/page.php?page=1

replaced: http://www.example.com/page/1

egdorm
  • 11
  • You can use the RewriteRule. Check this Question: http://stackoverflow.com/questions/2841502/rewriterule-question – Anas Jul 02 '12 at 21:25
  • possible duplicate of [mod_rewrite - how to rewrite an URL?](http://stackoverflow.com/questions/4660433/mod-rewrite-how-to-rewrite-an-url) – poke Jul 02 '12 at 21:25
  • You'll need to modify .htaccess (Apache) or create a Rewrite Rule (IIS). – Brian Driscoll Jul 02 '12 at 21:25
  • They usually implement an .htaccess url rewrite [for unix/linux machines]. The rules are contained in that file. For windows machines, another form of url rewrite is implemented but basically the same technique. – Dexter Huinda Jul 02 '12 at 21:27

2 Answers2

1

indeed, just what ssx said.

You need a .htaccess file in the root of the website, with some content that looks like this (i use this one)

RewriteEngine On 

RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([\(\)\|a-zA-Z0-9_-]+)/([0-9]+)/?$   /index.php?ext=$1&cat=$2&name=$3&urlID=$4 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([\(\)\|a-zA-Z0-9_-]+)/?$     /index.php?ext=$1&cat=$2&name=$3 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/p=([0-9]+)/?$     /index.php?ext=$1&cat=$2&p=$3 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$    /index.php?ext=$1&cat=$2 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/?$     /index.php?ext=$1 [L]  
Mathlight
  • 6,436
  • 17
  • 62
  • 107
0

I'd say take a look at an answer I provided someone else a while back. I'd type it all out here again or copy and paste it but the link is much easier.

PHP dynamic DB page rewrite URL

Community
  • 1
  • 1
chris
  • 36,115
  • 52
  • 143
  • 252