0

I have a dynamic site PhotographyAttic with the following code in my htaccess file

RewriteEngine on
RewriteBase /  

#Make dynamic url neater  
RewriteRule ^category-(.*)  category.php?catid=$1 
RewriteRule ^manufacturer-(.*)  manufacturer.php?manuid=$1
RewriteRule ^product-(.*)  product.php?id=$1  


#remove.php from end of url 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

#force www
Options +FollowSymLinks  
RewriteCond %{HTTP_HOST} !^www.photographyattic.com$ [NC]
RewriteRule ^(.*)$ http://www.photographyattic.com/$1 [L,R=301]

How do I fix the following error

http://www.photographyattic.com/category.php?catid=9 and http://photographyattic.com/category.php should resolve to the same URL, but currently do not.

Peter23
  • 97
  • 2
  • 8
  • Did you try to put the last rule in front of the other rules? If the rule for stripping .php matches, the L flag specifies no other rules should be processed, as you can read here: https://httpd.apache.org/docs/2.4/rewrite/flags.html – Arno Jan 24 '18 at 15:31
  • No I hadn't...tried now. I wasnt aware what L did, thanks. Does this mean my following two rules will be ignored? – Peter23 Jan 24 '18 at 15:41
  • What im trying to do is get a dynamic url from a mysql query to display a category, product or manufacturer without php at end of url, and with www. It works using the above htaccess file, but the error is flagging up in an seo test tool. And if I have a product page open and remove www from the url and try to visit the new url the original dynamic link product.php?id=$1 replaces the neater product-256 – Peter23 Jan 24 '18 at 15:48
  • As long as the condition of the "force www" rule is not met, the next rules will be parsed. – Arno Jan 24 '18 at 15:50
  • dont i want the "force www" to be met? and if so the other results wont be parsed? Sorry im clueless with this. I dont want category.php?catid=9 to resolve to category.php i want it to resolve to category-9. How do i do that? – Peter23 Jan 24 '18 at 16:07
  • If somebody is already on www.domain.tld then you dont want to redirect them to www.domain.tld again. This would result in an infinite loop. – Arno Jan 24 '18 at 16:09
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/163811/discussion-between-peter23-and-arno). – Peter23 Jan 24 '18 at 16:13

0 Answers0