max1234 Posted January 29, 2013 Share Posted January 29, 2013 Hi, I'm new to mod_rewrite. I've been writing websites for a while but programming is not my strong side so I would appreciate a little help with regards to mod_rewrite and how it works. I'm working at improving the SEO of my site and I have read that using mod_rewrite to make addresses more SEO friendly can help boost your rankings. Currently a product on my site may have an address as follows: http://www.mysite.co.uk/products.php?categoryfilename=productcategory.php&category=productcategory&id=PRODUCT-NAME where the productcategory.php is the page the user has just come from, the productcategory is the name of the category which is displayed on the page and PRODUCT-NAME is of course the name of the product. I'm thinking I will probably re-write to be something along the lines of: http://www.mysite.co.uk/productcategory/PRODUCT-NAME.php So my questions are: 1) The page pulls productcategory.php from the header and uses this as part of a hyperlink on the page. If I rewrite and don't include the php variable in the rewritten address does that matter. i.e. does the server pull the variables from the initial header or does it need the variables to be in the rewritten header? 2) Is there any negative in rewriting to folders? I've always been under the impression that the less sub directories you have the better for ranking. Therefore would I be better off rewriting something like: http://www.mysite.co.uk/productcategory-PRODUCT-NAME.php Thanks for help with this. I appreciate my code is messy. I'm trying to change! Quote Link to comment https://forums.phpfreaks.com/topic/273780-basic-mod_rewrite-help-required/ Share on other sites More sharing options...
requinix Posted January 29, 2013 Share Posted January 29, 2013 1. Why do you even need to put the previous page in the URL? It's actually a bad thing. And you can get it more reliably (not perfectly) from the HTTP_REFERER anyways. 2. Shallower folder structures are better, but really the URL doesn't matter a whole lot. SEOing your URLs will not give you much of a boost in rankings. Helps, yes, but it's not some magic bullet. Quote Link to comment https://forums.phpfreaks.com/topic/273780-basic-mod_rewrite-help-required/#findComment-1408905 Share on other sites More sharing options...
max1234 Posted January 29, 2013 Author Share Posted January 29, 2013 Hi requinix, In answer to your question about the previous page in the URL, probably bad programming. Usually users will be viewing a product on a category page. So perhaps they are viewing all red products in the category RED then they click on the product they want to look at. On the next page they can see the product but they can also click a hyperlink to go back to the category page. I'm sure there are ways to do this without putting red.php into the header but I was unable to get anything else to work. I'll try HTTP_REFERER Thanks Quote Link to comment https://forums.phpfreaks.com/topic/273780-basic-mod_rewrite-help-required/#findComment-1408908 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.