Mod rewrite issues

New to mod_rewrite? This is a good place to start.

Mod rewrite issues

Postby memyselfandi » Thu May 21, 2009 6:45 am

Hi all,

I am hoping you can help.

I have a website: http://www.me-myselfandi.co.uk.

When customers view my products they see the URL as follows:
http://www.me-myselfandi.co.uk/WebsiteP ... ductId=248
(the id changes for the appropriate product)

I want to change this so that the URL reads http://www.me-myselfandi.co.uk/(the product's name)

Ideally I would like it to pull the products name from the MySQL database, however I don't mind writing a rule for each product if needs be.

I am struggling to figure out how to write this code into a .htaccess file.

Please can someone help?

Thanks
memyselfandi
 
Posts: 2
Joined: Thu May 21, 2009 3:10 am

Postby richardk » Thu May 21, 2009 7:02 am

Ideally I would like it to pull the products name from the MySQL database

FAQ: How to change a numeric ID into a name/title.

however I don't mind writing a rule for each product if needs be.

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^productname$ /WebsitePages/description.php?productId=248 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby memyselfandi » Thu May 21, 2009 7:31 am

Thanks for that.

Do I just then save the file as .htaccess and ad it to the root folder or do I need to add it to every subfolder as well?

When I add this to my root folder I get the following message appear on the screen for every page:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webadmin@kundenserver.de and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.


Do you know why this is, I am using 1and1 for my hosting if that helps.

Thanks
memyselfandi
 
Posts: 2
Joined: Thu May 21, 2009 3:10 am

Postby richardk » Thu May 21, 2009 4:01 pm

Do I just then save the file as .htaccess and ad it to the root folder or do I need to add it to every subfolder as well?

Save what? The mod_rewrite from my post? You would save it in your document root for it to match /productname. If you saved it in /abc/.htaccess it would match /abc/productname.

When I add this to my root folder I get the following message appear on the screen for every page:

Look in your error log to see what is causing the error.
Try removing the Options line.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 98 guests

cron