0

For example i have

3 php pages

  1. www.example.com/page1.php?var1=data1&var2=data2&var3=data3
  2. www.example.com/page2.php?var1=data1&var2=data2&var3=data3
  3. www.example.com/page3.php?var1=data1&var2=data2&var3=data3

For good SEO . I need URL like

  1. www.example.com/page1/data1-data2-data3
  2. www.example.com/page2/data1-data2-data3
  3. www.example.com/page3/data1-data2-data3

I got something URL rewriting with PHP but am confused how to implement it for multiple dynamic PHP pages. i need all the variables for proper functioning of php pages

Community
  • 1
  • 1

2 Answers2

1

Put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteRule ^(page1|page2|page3)/([^-]+)-([^-]+)-([^-/]+)/?$ /$1.php?var1=$1&var2=$2&var3=$3 [L,QSA,NE]
anubhava
  • 761,203
  • 64
  • 569
  • 643
0

In your .htaccess you should add the line:

RewriteRule ^(\w+)/(\w+)-(\w+)-(\w+)$ /$1.php?var1=$2&var2=$3&var3=$4 [QSA]

The first part captures the page name (script name, in your case), then each successive query string parameter. The QSA key tells the redirect to take any additional query string parameters not specified explicitly along with the request.

jacobroufa
  • 371
  • 2
  • 8