Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6850411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:07:17+00:00 2026-05-27T01:07:17+00:00

I am really new to .htaccess. I was wondering how to create a complex

  • 0

I am really new to .htaccess. I was wondering how to create a complex seo friendly urls for the search string and selected filters.

I’m using following code currently for the search.

ReWriteRule ^search/(.*)/(.*)   ?module=search&q=$1&page=$2 [L]
ReWriteRule ^search/(.*)        ?module=search&q=$1 [L]

When it comes to adding filter options it starts to be a nightmare. Consider following filters;

Short by: none, name, date + ASC, DESC.
Category: none, category ID.
Search In: All, title, Message, Author.

When all filters are selected our address would be;

Raw :
http://www.site.com/?module=search&q=test&shortBy=name_ASC&catID=1&searchIn=title

Seo Friendly : http://www.site.com/search/test/name_ASC/1/title/

Now that’s not complex at all but I just want to understand the how things work.
Do I have to apply all the filters to URL even if they are not selected? This would create longer URLs for no reason so I believe there must be another approach to this.

How do I define the rule in .htaccess? As in my example, I am writing at least 2 rules in my .htaccess file (2nd one is for pagination).

All I could think right now to do something like this ^search/(.*)/(.*) ?module=search&$1=$2 [L] but this doesn’t look elegant.

I will be glad if you could help me out with this problem. I will be grateful if you could also share some of your experiences to a .htaccess newbie like I am.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:07:17+00:00Added an answer on May 27, 2026 at 1:07 am

    Put the rules below at the top of your .htaccess file (in the root directory of your site) and then select one of the options below, modify it to your needs and place in after in your .htaccess file.

    The first option will match the most urls and is not recommended. The second will only match urls with 5 directories, but requires all the paramters, so I recommend the 3rd.

    Though the pattern below may not look elegant, it is a featured solution in The Definitive Guide to Apache mod_rewrite

    For more details look at the apache docs or some examples or this post

    In all cases, I am assuming that the requests go to index.php, so you should modify this to match the actual page.

    This section should go at top of .htaccess file for all 3 options

    #for all 3 options these 2 lines should be at the top of the .htaccess file
    RewriteEngine On
    RewriteBase /
    

    Option1

    #1 if all parameters are optional, and you page (index.php) can handle blank parameters use
    RewriteRule ^([^/]*)/?([^/]*)/?([^/]*)/?([^/]*)/?([^/]*)/$ index.php?module=$1&q=$2&shortBy=$3&catID=$4&searchIn=$5 [L]
    

    Option2

    #2 if all parameters are required use
    RewriteRule ^([^/]+)/([^/]+)/([^/]+)?([^/]+)/([^/]+)/$ index.php?module=$1&q=$2&shortBy=$3&catID=$4&searchIn=$5 [L]
    

    Option3

    #3 if the module is required and other parameters are optional, then this is better
    RewriteCond %{REQUEST_URI} ^/(search|produce_detail|other_modules_here)/
    RewriteRule ^([^/]*)/?([^/]*)/?([^/]*)/?([^/]*)/$ index.php?module=%1&q=$1&shortBy=$2&catID=$3&searchIn=$4 [L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I am really new to rails and I am trying to create a
I am new to htaccess rules. I have tried to search about my questionm
I'm really new to erlang and I'm wondering how to manipulate xml. I've found
I am really new to HTML and was wondering how you center multiple links
I really new in Java....i work some research in java using tool Tapestry framework...
I'm really new at using Razor with MVC, and so far I really like
Being really new to wx, I'm wondering if there is an IDE (especially for
Really new to using jQuery and trying to find an example I need. 1)
im really new to flash, how do i go about creating a variable which
im really new to linq-to-SQL so this may sound like a really dumb question,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.