Reputation: 175
I set my .htaccess
like here;
this is exp. of my SeoFriendly url mysite.com/search/eminem/1/video.html
this is exp. of original url mysite.com/index.php?search=eminem&page=1&type=video
What i need to do is when i search for a word exp "eminem": mysite.com/index.php?search=eminem&page=1&type=video to be transformed in this url mysite.com/search/eminem/1/video.html
Here is an example http://mp3.x10demos.com/
I think i have to add a php function for my search form but i don't know how to do it.
Upvotes: 0
Views: 135
Reputation: 12322
What i need to do is when i search for a word exp "eminem": mysite.com/index.php?search=eminem&page=1&type=video to be transformed in this url mysite.com/search/eminem/1/video.html
I think what you need is the opposite. You should generate SEO-friendly links in your application and have .htaccess translate them into links readable for the app.
So on your site you should have a link to mysite.com/search/eminem/1/video.html
and add to .htaccess something like
RewriteRule ^search/(.*)/([0-9]+)/(.*).html$ index.php?search=$1&page=$2&type=$3 [L]
As metadice suggested the best way is to use a framework which will help facilitate this process. (e.g. Codeigniter)
Upvotes: 0
Reputation: 359
Just use " www.example.com/some/other.html " in all your pages when you link to that particular page. .htaccess will automatically covert and map it to original url. Google will index the links you put in your page which will be " www.example.com/some/other.html ". When someone will click on that url, .htaccess will come into action and will map that url to your original url.
Edit: If you have a search functionality on your site, and after searching you are getting that background url instead of that seo friendly url than I think you should look what url are you saving in the first palce. If you save background url than you will get background url in results and than you have to manually convert those results to seo friendly urls so try to save links in seo friendly format.
Edit: Actually you need to make some major changes to your "searchSuggest.php" file if this is the file where your search processing code is. The problem is your urls are converting but after the processing has been done. So I would strongly suggest you to go with Codeigniter
it is a very popular php framework otherwise things will get complicated further more. When u will use codeigniter your search processing script will take it's url in the form in mysite.com/search/eminem/1/video.html process it and will output results in the seo friendly urls.
Upvotes: 1