0

My index page's URL can contain multiple different variables, like:

index.php?page=page1
index.php?page=page2
index.php?page=page3
index.php?page=page4

How would I use .htaccess to shorten these URLs so that they look like this:

index.php/page1
index.php/page2
index.php/page3
index.php/page4

Thanks.

  • please, let us know if an answer solved your question. If so, please mark the question as 'solved', so help you others ! – DaveG Oct 09 '14 at 12:42

2 Answers2

0

You do not need rewrite rule for this. What exactly is PATH_INFO in PHP?

Just look at $_SERVER['PATH_INFO']

Community
  • 1
  • 1
Cheery
  • 16,063
  • 42
  • 57
0

You could also use the following code in .htaccess to generate friendly urls (this is what you need to search for if you want to know more about this):

RewriteEngine On
RewriteRule ^(.*)$ ./index.php?page=$1

this will let you use

yourdomain.com/page1 => yourdomain.com/index.php?page=page1
yourdomain.com/page2 => yourdomain.com/index.php?page=page2
yourdomain.com/page3 => yourdomain.com/index.php?page=page3
yourdomain.com/...   => yourdomain.com/index.php?page=...
DaveG
  • 741
  • 6
  • 16