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

  • SEARCH
  • Home
  • 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 7524625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:07:15+00:00 2026-05-30T03:07:15+00:00

I need to rewrite URL like http://www.example.com/search.php?abc to http://www.example.com/abc using the rules below, but

  • 0

I need to rewrite URL like http://www.example.com/search.php?abc
to http://www.example.com/abc
using the rules below, but it doesn’t work, why doesn’t it match?

RewriteCond %{REQUEST_URI} ^search.php
RewriteRule ^search.php?q=([-0-9a-zA-Z]+) $1
  • 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-30T03:07:16+00:00Added an answer on May 30, 2026 at 3:07 am
    • %{REQUEST_URI} always has a / at the start. so RewriteCond %{REQUEST_URI} ^search.php will never match.

    • RewriteRule Directive

      Pattern is a perl compatible regular expression. On the first RewriteRule it is applied to the (%-decoded) URL-path of the request; subsequent patterns are applied to the output of the last matched RewriteRule.

    • ? means match for one or none of previous character when not escaped. So your ^search.php?q=... would match:

      • search.phpq=...
      • search.phq=...

    from PCRE man pages

    ? extends the meaning of (
    also 0 or 1 quantifier
    also quantifier minimizer

    You will have to do this:

    Options +FollowSymLinks
    RewriteEngine On
    
    RewriteCond %{ENV:REDIRECT_STATUS} 200
    RewriteRule ^ - [L]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteCond %{REQUEST_URI} ^/([\w]+)/?$ [NC]
    RewriteRule ^ search.php?q=%1 [L,QSA]
    
    RewriteCond %{REQUEST_URI} ^/search.php [NC]
    RewriteCond %{QUERY_STRING} ^q=([\w\d-]+)$ [NC]
    RewriteRule ^ /%1? [L,R=301]
    

    • Flag NC (nocase) : flag_nc Apache Docs
    • Flag L (last)         : flag_l Apache Docs
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help to rewrite URL with htaccess, now my url is http://site.com/index.php?user=ln12666279n i
I am wanting to rewrite a url like: http://my.project/mydomain.com/ANY_NUMBER_OF_CATEGORIES/designer/4/designer-name/page.html to this: http://my.projects/mydomain.com/ANY_NUMBER_OF_CATEGORIES/page.html?designer=4 I would
I've got a number of users, each with the website page like http://www.mysite.com/folder/artist_id.php?id=33 The
I need help to redirect the following URL (in htaccess) http:www.domain.com/article/the-bp-oil-spill-one-year-later/19918396/20110420/ To http:www.domain.com/article/the-bp-oil-spill-one-year-later/19918396/2011/04/20/ my
I have the following page: www.domain.com/index.php?route=information/contact and I'd like to rewrite it so that
I want to get a URL scheme exact like SO's question URL. Like http://stackoverflow.com/questions/6035363/so-like-url-with-mod-rewrite
I need advice, I've installed facebook/google+ on my wordpress category pages. For example: http://www.sandrophoto.com/category/famous-photographers/
I have url rewrite rules which redirect www.domain2.com to a subfolder under the root
I have this url: http://www.mydomain.com/index.html And want a rule to rewrite the above into
I'm trying to use URL rewrite in my new project. But I also need

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.