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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:11:14+00:00 2026-06-08T02:11:14+00:00

I need a little help on this one. I’m in the process of making

  • 0

I need a little help on this one.

I’m in the process of making a php page that collects a query string, tests it against a database for matches, and then redirects the user to a different section of the site.

The is how it works currently (without htaccess/mod_rewrite):

  1. User visits: domain.com/redirect/index.php?slug=Test_1
  2. The php page sanitizes and looks up ‘Test_1’ in the database and retrieves a destination URL to redirect the user to. (e.g. domain.com/New_Test_1)
  3. The php page then 301 redirects accordingly.

This part is working fine. However, due to some variables outside of my control, I need to interpret the original URL (using htaccess/mod_rewrite), like this:

  • domain.com/redirect/index.php/Test_1

Which still acts the same as:

  • domain.com/redirect/index.php?slug=Test_1

(note: yes, the index.php needs to stay in the url.)

I have this working with the following in my htaccess, but I know it could be better:

RewriteEngine On
Options +FollowSymLinks

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)$ %{DOCUMENT_ROOT}/redirect/index.php?slug=$2 [PT,L,QSA]

Part I need help with…

Some of the old url slugs had forward slashes in them, like this:

  • domain.com/redirect/index.php?slug=How_to_Code/Program

Without htaccess, the above still works, but fails with the pretty(ier) url:

  • domain.com/redirect/index.php/How_to_Code/Program

With my current htaccess, it only captures the ‘How_to_Code’ part, but ignores everything after it.

So my question is this: how can I restructure my htaccess to grab everything after domain.com/redirect/index.php/(.*)$, including forward slashes?

Edit: this .htaccess is going inside the /redirect directory

  • 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-08T02:11:16+00:00Added an answer on June 8, 2026 at 2:11 am

    If you do this

    RewriteRule ^redirect/index.php/([a-zA-Z0-9/_]+)$ redirect/index.php?slug=$1
    

    That will accept forward slashes and underscores. To add anymore allowed characters just add them inside the [] square brackets. Certain characters may need to be escaped so just Google that.

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

Sidebar

Related Questions

need a little help with this one. I have a form that I am
Need a little help with a regex I'm trying to match a string that
Need a little help: I'm using jquery treeview plugin (this one: http://bassistance.de/jquery-plugins/jquery-plugin-treeview/ ). And
I'm so close on this one, but I need a little help. I have
I need a little help getting this script doing what I want it to.
I need a little help with this.. I need to take only the numbers
I'm quite new to this Git thing and need a little help. I recently
I know I'm close to figuring this out but need a little help. What
Need a little help with a SQL / ActiveRecord query. Let's say I have
I need a little help with an if statement in php. I'm trying to

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.