user2354788
user2354788

Reputation: 1

Mod rewire to shorten url but end up with not found error

My website, interspire shopping cart based, generates link like that:

http://abcd.com/products/Mac-Pro.html (Mac Pro is in Apple Catalog)

Which is very ugly and not seo friendly.

I need it become below using .htaccess mod rewrite only

http://abcd.com/Apple/Mac-Pro.html

I used:

 RewriteRule .* index.php/$0 [PT]

But my server says back:

Not Found

The requested URL /products/ was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Help me to shorten the url but not with that error.

Upvotes: 0

Views: 228

Answers (1)

Bobulous
Bobulous

Reputation: 13169

You need to switch your rule to the following:

RewriteEngine On
RewriteRule .* /index.php?path=$0 [PT]

This way the path being requested is silently passed to your index.php script in the query string in a variable called path.

Then in your index.php script you can get this value from the variable $_GET['path'] like this:

$path_requested = $_GET['path'];

Upvotes: 0

Related Questions