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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:47:08+00:00 2026-06-09T23:47:08+00:00

How can I make clean URL’s with one, two OR three variables? I want

  • 0

How can I make clean URL’s with one, two OR three variables?

I want domain.com/mypage to direct to index.php?page=mypage and
domain.com/mypage/myproduct to redirect to index.php?page=mypage&var2=myproduct and domain.com/mypage/myproduct/detail to redirect to index.php?page=mypage&var2=myproduct&var3=detail. So some pages have three variables, others have only one or two.

This is the .htaccess I’m using (it includes a part I found at htaccess rewrite pass two variables or one depending if both are available?):

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

It’s working for links with one or two variables. How can I make it work for three (or more) variables.

  • 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-09T23:47:09+00:00Added an answer on June 9, 2026 at 11:47 pm

    It’s probably easiest to just do each of them separately:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /index.php?page=$1&var1=$2&var2=$3 [L,QSA]
    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteRule ^([^/]+)/([^/]+)/?$ /index.php?page=$1&var1=$2 [L,QSA]
    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteRule ^([^/]+)/?$ /index.php?page=$1 [L,QSA]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can make a variable's name from two variables' value: $a = 'tea'; $b
I hope I can make myself clear in English and in what I want
I need a certain part of a URL extracted. Example: http://www.domain.com/blog/entry-title/?standalone=1 is the given
this is the url my application uses http://mydomain.com/index.php http://mydomain.com/video.php?id=29 http://mydomain.com/news.php?id=33 http://mydomain.com/photos.php?albumid=10 http://mydomain.com/archive.php http://mydomain.com/album.php http://mydomain.com/contact.php
I am planning to make clean URLs with htaccess as in php url routing
I think question is clear. I want to handle url strings which can be
1) Custom exceptions can help make your intentions clear. How can this be? The
Let's see if I can make the step-by-step clear: namespace InventoryManager.Controllers { public class
I will try to make this as clear as I can, but if you
Does it make sense to obsfucate Javascript? The only clear benefits I can see

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.