I am utilizing mod-rewrite and my htaccess file to translate query string urls to friendly ones. These are products that pull from a database and which populate a single dynamic php file - product1.php.
I introduced this rewrite function fairly recently and have seen my site traffic plummet. I am thinking this is because I need to add 301 redirects to the rewritten urls. (I have noticed a massive spike in url errors, mostly nonsensical, for some reason.)
Can you use 301 redirects if it's just one file (product1.php), only the url's are different; and, if so, how do you write it? I have searched this specific question, no luck.
FYI, here's what I have currently in my htaccess utilizing mod-rewrite:
RewriteEngine On
#Redirect all requests missing "www"
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
#Truncate extension ".php" from requests
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php$ /$1 [L,R=301,NC,NE]
#Look for the word "category" followed by slash, product type, slash, model name and model id, slash, product id
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^category/.*/.*/([0-9]+)$ product1.php?product-id=$1 [L,QSA]
#Rewrite static file url
RewriteRule ^category/subcategory/?$ subcategory-index.php [NC]
I have about forty of this last rewrite for the various static pages I am renaming.
Thanks :)