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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:34:11+00:00 2026-05-15T13:34:11+00:00

I have a solution but it is one that I know is not the

  • 0

I have a solution but it is one that I know is not the greatest and would better be solved with a full rewrite. Basically I have 3 rewrites that will go to the correct areas I want and do what they need to do. However in order to switch between where I need to go I had to write a URI class to strip through the url set the page and vars manually. It all works out great but the urls are a pain in the ass specially if not formatted exactly.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/bsiadmin/$ /bsiadmin/index.php [L,QSA]
RewriteRule ^/bsiadmin/(.+)/$ /bsiadmin/index.php?page=$1 [L,QSA]
RewriteRule ^/(.+)/$ /index.php?page=$1 [QSA]

So the first rule will make sure to direct everything to the directory and not the root index.php, the second rule does the same if there is a “page” specified. The last rule will take anything else and make sure it uses the root index.php and goes from there.

Example of urls:

http://mysite.test/icecream/id=2/

My custom uri class would strip this clean and set id as a $_REQUEST var.

I guess what I really want to know is how can I just rewrite a simple url such as:

http://mysite.test?page=icecream&id=2

AS

http://mysite.test/icecream/id/2/

Without any limitation on how many vars can be passed and the directory that does exist “bsiadmin” to display without me having to use a uri class to direct it.

Thanks for the help.

  • 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-15T13:34:12+00:00Added an answer on May 15, 2026 at 1:34 pm

    You can use mod_rewrite to do so:

    RewriteRule ^/([^/]+)/([^/]+)/([^/]+)/(.*) /$1/$4?$2=$3 [N,QSA]
    RewriteRule ^/([^/]+)/$ /bsiadmin/index.php?page=$1 [L,QSA]
    

    But I think the best would be to use PHP for that job. Because with mod_rewrite you can only rewrite a fixed amount of URL arguments at a time (here one with every rewrite). With PHP you can parse any arbitrary number of arguments like this:

    $_SERVER['REQUEST_URI_PATH'] = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
    $segments = explode('/', $_SERVER['REQUEST_URI_PATH']);
    if (count($segments) > 2) {
        for ($i=4, $n=count($segments); $i<$n; $i+=2) {
            $_GET[rawurledecode($segments[$i-1])] = rawurldecode($segments[$i]);
        }
        $_GET['page'] = rawurldecode($segments[1]);
    }
    

    Then all you need for mod_rewrite is this single rule to rewrite the requests to your index.php:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule !^/bsiadmin/index\.php$ /bsiadmin/index.php [L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that you can cache the WSDL but is there a way to
We have 2 systems at work that we pay for and we don't use
I guess this is a really simple question and, probably, one that has been
I have a problem that is seemingly solvable by enumerating all possible solutions and
I have a question that doesn't need any specific answer, just a general direction
I have read a lot of the MongoDB. I like all the features it
With StompChicken's corrections (I miscomputed one dot product, ugh!) the answer appears to be
At work, we use jQuery. Shortly after we started using it, I saw that
I'm developing a shopping comparison website, and the project is in a very advanced
Scenario: I'm trying to intercept paste events inside a textarea/input text, and filter the

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.