Need Help for directory base SEO Url in htaccess

  • gdhanasekar
  • Beginner
  • Beginner
  • User avatar
  • Posts: 50

Post 3+ Months Ago

Hi,

I am implementing the seo url in my site.The seo url is like directory based url, for example

example-site.com/index.php?module=site&content=page_categories&type=pages&id=mysql

to

example-site.com/index/module/site/content/page_categories/type/pages/id/mysql/

By using

RewriteRule index/module/(.*)/content/(.*)/type/(.*)/id/(.*)/ index.php?module=$1&content=$2&type=$3&id=$4

this is working fine,but I have to do this for each and every page of my site to generate seo urls.

Is there any other ways to implement the above directory like seo url using simple method?

Just I want all the GET parameters in my url instead of &,=
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Truce
  • Guru
  • Guru
  • Truce
  • Posts: 1477
  • Loc: Washington DC

Post 3+ Months Ago

You can certainly write more complex rewrite rules (and rewrite conditions) and structure your website to handle everything better, but it really depends on how you have everything setup.

By the way, you don't need to have 'module', 'content', 'type', or 'id' in your urls so long as the values are always in the same order and always filled in.

Code: [ Select ]
http://example.com/page/[id]/[title]
--> http://example.com/page.php?id=[id]&title=[title]

http://example.com/forum/[forumid]/[threadid]/[threadtitle]
--> http://example.com/forums/index.php?forum=[forumid]&thread=[threadid]

RewriteRule ^page/([0-9]+)/([a-zA-Z0-9_-])+/?$ /page.php?id=$1&title=$2
RewriteRule ^forums?/([0-9]+)/([0-9]+)/.* /forums/index.php?forum=$1&thread=$2
  1. http://example.com/page/[id]/[title]
  2. --> http://example.com/page.php?id=[id]&title=[title]
  3. http://example.com/forum/[forumid]/[threadid]/[threadtitle]
  4. --> http://example.com/forums/index.php?forum=[forumid]&thread=[threadid]
  5. RewriteRule ^page/([0-9]+)/([a-zA-Z0-9_-])+/?$ /page.php?id=$1&title=$2
  6. RewriteRule ^forums?/([0-9]+)/([0-9]+)/.* /forums/index.php?forum=$1&thread=$2


Note that in the last rewriterule I added a question mark after the forums part. That means it will allow forum/... or forums/... and handle it the same. Doing what users expect is a big user-interface perk!

I hope that helps answer your question.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 75 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.