Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/273780-basic-mod_rewrite-help-required/
Share on other sites

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.

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.