0
votes

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

2
This question appears to be off-topic because it is about SEO and too broadJohn Conde

2 Answers

1
votes

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]
0
votes

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.