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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:19:44+00:00 2026-05-22T16:19:44+00:00

Right now I have a rewrite rule that looks like this: RewriteRule ^product-([a-z^-]+).php /sample.php?m=$1

  • 0

Right now I have a rewrite rule that looks like this:

RewriteRule ^product-([a-z^-]+).php /sample.php?m=$1

If I try going to “product-test.php”, it works fine.

If I try going to “product-test.php?variable=1”, it will not work.

How can I modify the rewrite rule to allow the GET variable?

NOTE: The GET variable should only allow letters (Aa-Zz) and dashes (-).

  • 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-22T16:19:44+00:00Added an answer on May 22, 2026 at 4:19 pm

    I believe it should read

    RewriteRule ^product-([A-Za-z\-]+).php /sample.php?m=$1&%{QUERY_STRING}
    

    Note the backslash escaping the dash. The dash is an operator in the matching portion, so it must be escaped.

    Also, to include GET variables with a rewritten url without rewriting them, append the query string identifier to the end.

    This will rewrite:

    www.example.com/product-widget.php?variable=12

    to

    www.example.com/sample.php?m=widget&variable=12

    Which is what I believe you are going for.

    That having been said, I’m not sure escaping the dash actually works, as I’ve just discovered a problem using a dash in my rewritten urls that I can’t seem to resolve. It’s like the Apache 1.3.33 rewrite module doesn’t like the dash in the rewrite string. Anyways, this is how it should work, and it works on my server.

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

Sidebar

Related Questions

I have a .htaccess file which right now looks like this: Options +FollowSymLinks RewriteEngine
I have this rewrite rule that turns foo.com/test (or foo.com/test/) into foo.com/test.txt: RewriteRule ^test/?$
I have this setup right now... RewriteRule ^/?user userpanel.php RewriteRule ^/?user/?newListing newListing.php The above
Right now I'm doing something like this: RewriteRule ^/?logout(/)?$ logout.php RewriteRule ^/?config(/)?$ config.php I
Right now, I have: RewriteRule ^([^/\.]+)?$ index.php?id=$1 [L] to match any username at the
Right now I have a PHP file that does a MYSQL query and then
I need to have mysite.com/comment.php?id=sasdfkjsfj redirected to mysite.com/sasdfkjsfj. Right now, i'm using this code
I have this problem where all URLs like context/path/file/anything/that/follows becomes context/path/file.php/anything/that/follows or context/path/file.xml/anything/that/follows .
Right now I have a script that will get the last five files in
Right now I have a function, in a class that is used to listen

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.