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 8780109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:57:38+00:00 2026-06-13T19:57:38+00:00

I have the following .htaccess Rewrite rule below which works for converting virtual directories

  • 0

I have the following .htaccess Rewrite rule below which works for converting virtual directories to parameters, for example:

www.example.com/usa/ny/nyc gets interpreted by PHP as www.example.com/index.php?path=usa/ny/nyc.

What I can’t seem to figure out is how I would change my regex below to handle parameters of the virtual directories themselves. For example, I want:

www.example.com/usa/ny/nyc/?display=off&settings=none to be seen by PHP as www.example.com/index.php?path=usa/ny/nyc&param=display:off,settings:none.

What makes it extra tricky is that the parameters won’t always be those two options I used in the example above, they will change dynamically. Any ideas or suggestions of how to go about accomplishing this?

RewriteRule ^/?([a-zA-Z_\-/]+)$ index.php?path=$1 [L]  
  • 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-06-13T19:57:40+00:00Added an answer on June 13, 2026 at 7:57 pm

    Assuming you want to pass the query string unmodified, you can use the [QSA] (query string append) option like so:

    RewriteRule /(.+)$ /index.php?path=$1 [L,QSA]
    

    You can find the documentation for the QSA option here. From the docs:

    With the [QSA] flag, a request for /pages/123?one=two will be mapped
    to /page.php?page=123&one=two. Without the [QSA] flag, that same
    request will be mapped to /page.php?page=123 – that is, the existing
    query string will be discarded.

    So, your PHP script will see all the parameters as standard _$_GET parameters, rather than needing to do any other modification.

    If you would prefer to treat the result more like a typical path element, you can use the following:

    RewriteRule /(.+)$ /index.php/$1 [L,QSA]
    

    In the above case, your query string will still be appended, however you will need to handle the path explicitly using $_SERVER['PATH_INFO'].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following rewrite rule in my htaccess file, which I found suggested
I have the following .htaccess rule: RewriteEngine on RewriteRule ^(.*) http://www.server2.com/index.php?action=$1 I need to
I have a rewrite rule in my htaccess file like in the following example:
I currently have the following htaccess rewrite rule: RewriteRule (.*) index.php/$1 [L] How do
I have the following .htaccess config RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^example.com [NC]
I need an .htaccess rewrite rule that will redirect links like this: www.mydomain.com/viewpressrelease.php www.mydomain.com/viewpressrelease.php?id=17
I have the following rewrite rule in my .htaccess file on the root of
I am using php CodeIgniter and have the following rewrite rule in my .htaccess
I need to rewrite a rule using htaccess, I currently have the following: RewriteRule
I have the following rewrite rule in my .htaccess file: RewriteRule ^([^/]+)/([^/]+)/(tab:([^/]+)/?)?(scope:([^/]+)/?)?(sort:([^/]+)/?)?(p:\d+)/?)?$ web/results.php?view=$1&q=$2&tab=$4&searchscope=$6&sortBy=$8&page=$10 [NC,QSA,L]

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.