Jump to content

How to make SEO friendly URL's work. Help... *** SOLVED *** :)


Recommended Posts

I am confused as to what to rename the htaccess file to

It was ".htaccess.txt" but I have to drop the "txt" part off the end. But do I keep the full stop/period (.) ?

Is it this ".htaccess" or this "htaccess." ???


It really seems to make no difference. With the SEO Friendly url turned on in the back office and me renaming the file to either one still does not allow the friendly url to work.
All that happens is:

The actual URL will show this: http://www.XYZ.com/5-mig-wire
But the page comes up as a 404 error.

How can I fix this?

I really need to get this working, not just for the SEO value but also in google analytics so that I can see what people are looking at. Right now all I get is the long non english coded text url.

Peter

Link to comment
Share on other sites

Okay this is what I have in my htaccess.txt file right now.

-----------------------------------------------------------------
# URL rewriting module activation
RewriteEngine on

# URL rewriting rules
RewriteRule ^([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ product.php?id_product=$2$4 [L,E]
RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ product.php?id_product=$1$3 [L,E]
RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ category.php?id_category=$1 [QSA,L,E]
RewriteRule ^content/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ cms.php?id_cms=$1 [QSA,L,E]
RewriteRule ^([0-9]+)__([a-zA-Z0-9-]*)(.*)$ supplier.php?id_supplier=$1$3 [QSA,L,E]
RewriteRule ^([0-9]+)_([a-zA-Z0-9-]*)(.*)$ manufacturer.php?id_manufacturer=$1$3 [QSA,L,E]

# Catch 404 errors
ErrorDocument 404 /404.php

--------------------------------------------------------------------

Can you just copy and paste in your next post what I should use. I am still skeptical as I have tried a few different version of the htaccess code.

Peter

Link to comment
Share on other sites

try this below, it looks like you are missing a / for the product, category, supplier and manufacturer lines.(you will see the first one in front of the word "product". also be aware I have put a slash in front of the cms line as this helps my setup but not sure if will help yours so try with and without /cms.

yours shows number 1. instead of just a hash # sign though this may be because of a lost translation in the posting. anyway they should be # hash at the front of just the comment lines as you probably know.

REMEMBER ... compare this to your own thoroughly and take a backup copy of your.htaccess so you can flip it back if its wrong.(this should work)

good luck
John


# URL rewriting module activation
RewriteEngine on

# URL rewriting rules
RewriteRule ^([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ /product.php?id_product=$2$4 [L,E]
RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ /product.php?id_product=$1$3 [L,E]
RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ /category.php?id_category=$1 [QSA,L,E]
RewriteRule ^content/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ /cms.php?id_cms=$1 [QSA,L,E]
RewriteRule ^([0-9]+)__([a-zA-Z0-9-]*)(.*)$ /supplier.php?id_supplier=$1$3 [QSA,L,E]
RewriteRule ^([0-9]+)_([a-zA-Z0-9-]*)(.*)$ /manufacturer.php?id_manufacturer=$1$3 [QSA,L,E]

# Catch 404 errors
ErrorDocument 404 /404.php

Link to comment
Share on other sites

Nope still can't get it to work.

that is even when I change the 1. to a #
and even changing the /cms to just cms

I still get the 404
But have noticed that If you search for say "mig wire" in the search box, it will show a list of items, but then when you click to "view" the item it deos the 404 thing again.

Peter

Link to comment
Share on other sites

Strange, there must be something wrong in the rules, I have done lost of these and it always seems to come back to the "/" in the right place, for instance one of my shops is in a subfolder i.e www/mysite.com/prestashop, so the / would then be

RewriteRule ^([0-9]+)\-([a-zA-Z0-9-])\.html(.)$ /PRESTAHOP/product.php?id_product=$1$3 [L,E]

if you still struggle I can have a look at it through FTP if you want to PM me the details, 2 pairs of eyes are better than one etc. remember to back up before you send me anything.

John

Link to comment
Share on other sites

Okay so I can now tell you that my shop is also in a subfolder.

it is something like this.

/public_html - this is my first website that is all just stored in this folder.

Then my prestashop is under this path or

So maybe I should try to put in XYZ.com (the name of the folder) between the two slashes like this

/XYZ.com/

What do you think? Well I'm going to try it anyway, lol.

Peter

Link to comment
Share on other sites

your site knows the first part so if you are in a subfolder you will only need the rewrite rules to be told the sub i.e. www.yoursite.com(your rewrite knows this bit) so in the rules you should put the subfolder if it has one, i.e.

RewriteRule ^([0-9]+)\-([a-zA-Z0-9-])\.html(.)$ /subfolder_name_here/product.php?id_product=$1$3 [L,E]

this is all it can be, also try turn off seo friendly before change then turn back on after change!

Link to comment
Share on other sites

Would this be correct below?



I tried that and no good either.

I then added it to all the lines, no go either.


Should I email hostgator for help? If so what should I specifically ask for? Just if the allow URL rewrites?

Peter

Link to comment
Share on other sites

you dont need the bit that says

the rest you need but I think you tried this... check hostgator is the best bet. Yes ask them if they allow url rewrtiting, they will look at your code at their end and check it out.

sorry I couldnt help, if you think of anything else let me know

John

Link to comment
Share on other sites

Holy crap, it works....

You know what. It had nothing to do with the actual code. Well so I think.

What gave me the clue was when you mentioned to use FTP. I was just going into cpanel on the server. Here was the problem, human error.

The file had to be named .htaccess all the other files when viewed in cpanel are all showing without the . in place at the front.

So I go on via FTP and low an behold there are a few files that have the . showing in front of them. I add the . and preto it works.....

Except the php code line thing that you gave me in the PM you sent did make the page go all messed up. But other than that it seems to be working now.

THANKS a MILLION. IT was one of those simple little mistakes..

My next problem is SSL, I will start another thread for that.

Cheers,
Peter

Link to comment
Share on other sites

that is right but trust me...the spaces were not allowed as I tried it with and without the spaces here and it wouldnt work. at soe stage you moved just 3 spaces without knowing it, so if you move it in future be aware of this also.
Anyway, well done

John

Link to comment
Share on other sites

  • 7 months later...

Hello All,

Has anyone got the Friendly Urls to work with Hostgator? I have enabled them and created the htaccess file however, i keep getting the following for every link except the manufacturers box:

We're sorry, but the Web address you entered is no longer available

Any Ideas?

Andrew

Link to comment
Share on other sites

×
×
  • Create New...