Redirecting friendly urls to index

Discuss practical ways rearrange URLs using mod_rewrite.

Redirecting friendly urls to index

Postby blackshark » Fri Aug 15, 2008 11:51 am

How I can redirect a bunch of urls like
www.site.com/keyword.html
www.site.com/keyword-keyword.html
www.site.com/keyword-cars.html
www.site.com/keyword-houses.html

etc.. to the index of the site(www.site.com)

Should I add something to the friendly links to be recognized by mod rewrite? like:
www.site.com/1-keyword.html
www.site.com/1-keyword-keyword.html
www.site.com/1-keyword-cars.html
www.site.com/1-keyword-houses.html

any ideas?
blackshark
 
Posts: 11
Joined: Mon Dec 17, 2007 11:53 am

Postby richardk » Sat Aug 16, 2008 3:26 pm

I'm not quite sure what you want.

Your current URLs are /keyword.html and you want to redirect them (change the URL in the browser) so they go to /?

Or are you creating new keyword URLs?
Do you have some existing HTML files?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby blackshark » Sun Aug 17, 2008 12:16 am

The links are dinamic. Every link represents a tag.
I have a tag cloud that has 100 words with 100 links. ex:
word: keyword
link: www.site.com/keyword.html

I want that all this urls to be redirected to the site root( / )
blackshark
 
Posts: 11
Joined: Mon Dec 17, 2007 11:53 am

Postby richardk » Mon Aug 18, 2008 4:51 pm

Do you have existing HTML files?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^[^/]+\.html$ /? [R=302,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 6 guests

cron