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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:09:41+00:00 2026-05-29T08:09:41+00:00

UPDATE: Solution at bottom. I recently switched from using a set up such as

  • 0

UPDATE: Solution at bottom.

I recently switched from using a set up such as index.php?p=page_name&o=temporary_override and switched to clean urls such as /page_name/temporary_override. The temporary override is just so I can see the results of the site changes while it’s being built.

I currently have mod_rewrite set to:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?GHPAGE=$1 [L,QSA]

Which will capture the “subdirectories” and then PHP parses the URL from the GHPAGE $_GET var. What I want is to set up a 301 redirect so that anyone using index.php?p=something&o=something_else will get redirected to /something/something_else. Any idea how I can accomplish this? The p & o may come in any order and one or the other may not exist.

EDIT: Ok, after help from @Jon-Lin, @dambrisco, and @anubhava, I have gotten closer. My .htaccess file now looks like:

RewriteEngine On
#Base Directory
RewriteBase /test/

#if 2 GET Vars
RewriteCond %{THE_REQUEST} ^([A-Z]{3,9})\ \/([^\/]+\/)*(index\.php)?\?[op]=([^&]+)&[op]=(.+)\ HTTP\/
RewriteRule ^index\.php$ /%4/%5 [R=301,L]
#if 1 GET Var
RewriteCond %{THE_REQUEST} ^([A-Z]{3,9})\ \/([^\/]+\/)*(index\.php)?\?[op]=(.+)\ HTTP\/
RewriteRule ^index\.php$ /%4 [R=301,L]
#Remove index.php
RewriteCond %{THE_REQUEST} ^([A-Z]{3,9})\ \/([^\/]+\/)*index\.php\ HTTP\/
RewriteRule ^index\.php$ / [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?GHPAGE=$1 [L,QSA]

It is now redirecting, but not quite where it needs to go. root/test/index.php?p=test&o=override now redirects to root/test/override?p=test&o=override. Closer, but I can’t figure out how to get rid of the GET vars which are being added to the URL or why it’s redirecting to the root directory instead of to the RewriteBase directory.

EDIT:

It’s now redirecting properly, but for some reason it’s dropping the /test/ RewriteBase folder from the equation. http://www.domain.com/test/index.php?p=page1&o=operation is getting redirected to http://www.domain.com/page1/operation. New .htaccess file is below:

RewriteEngine On

RewriteBase /test/

#if 2 GET Vars
RewriteCond %{THE_REQUEST} ^([A-Z]{3,9})\ /([^/]+/)*(index\.php)?\?[op]=([^&]+)&[op]=(.+)\ HTTP\/
RewriteRule ^ /%4/%5? [R=301,L]

#if 1 GET Var
RewriteCond %{THE_REQUEST} ^([A-Z]{3,9})\ /([^/]+/)*(index\.php)?\?[op]=(.+)\ HTTP\/
RewriteRule ^ /%4? [R=301,L]

#if index.php
RewriteCond %{THE_REQUEST} ^([A-Z]{3,9})\ \/([^\/]+\/)*index\.php\ HTTP\/
RewriteRule ^index\.php$ /$ [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?GHPAGE=$1 [L,QSA]

Thanks everyone. Question has been solved. Final .htaccess is below for reference.

RewriteEngine On

RewriteBase /test/

#if 2 GET Vars
RewriteCond %{THE_REQUEST} ^([A-Z]{3,9})\ /([^/]+/)*(index\.php)?\?[op]=([^&]+)&[op]=(.+)\ HTTP\/
RewriteRule ^ %4/%5? [R=301,L]

#if 1 GET Var
RewriteCond %{THE_REQUEST} ^([A-Z]{3,9})\ /([^/]+/)*(index\.php)?\?[op]=(.+)\ HTTP\/
RewriteRule ^ %4? [R=301,L]

#if index.php
RewriteCond %{THE_REQUEST} ^([A-Z]{3,9})\ \/([^\/]+\/)*index\.php\ HTTP\/
RewriteRule ^index\.php$ ? [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?GHPAGE=$1 [L,QSA]
  • 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-29T08:09:42+00:00Added an answer on May 29, 2026 at 8:09 am

    Add this somewhere in your htaccess:

    RewriteCond %{THE_REQUEST} ^([A-Z]{3,9})\ /index\.php\?p=([^&]+)&o=(.+)\ HTTP
    RewriteRule index.php /%2/%3 [R=301,L]
    

    And if you want to cover the case where there’s no “temporary_override”, add this too:

    RewriteCond %{THE_REQUEST} ^([A-Z]{3,9})\ /index\.php\?p=(.+)\ HTTP
    RewriteRule index.php /%2 [R=301,L]
    

    Closer, but I can’t figure out how to get rid of the GET vars which are being added to the URL or why it’s redirecting to the root directory instead of to the RewriteBase directory

    Add a ? at the end of /%4/%5 to get rid of the query string. And remove the leading / from /%4/%5 to keep it from rewriting to the root. So, for example, one of your rules should look like this:

    RewriteCond %{THE_REQUEST} ^([A-Z]{3,9})\ \/([^\/]+\/)*(index\.php)?\?[op]=([^&]+)&[op]=(.+)\ HTTP\/
    RewriteRule ^index\.php$ %4/%5? [R=301,L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not interested in any auto update solution, such as ClickOnce or the
Update: We are still using XP at work and I got my solution working,
UPDATE: SOLUTION AT BOTTOM I'm hoping someone else has spent some time ironing out
Update: This issue is caused by bad memory usage, see solution at the bottom.
Update: I found the solution, look in the bottom of this page... I've got
NOTE: I added my new solution at the UPDATE answer below. I try to
Update: This question was an epic failure, but here's the working solution. It's based
UPDATE: Focus your answers on hardware solutions please. What hardware/tools/add-in are you using to
See the solution at the bottom of the question. IE 8 (and lower) does
Sample page On the sample page I have set div#content { padding-bottom:20px; } which

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.