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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:32:34+00:00 2026-06-13T07:32:34+00:00

I am beginner in Apache rewrite URL. I have a problem to rewrite URL.

  • 0

I am beginner in Apache rewrite URL.

I have a problem to rewrite URL.

I would like to rewrite http://www.test.com/abc/index.php?val=123 to http://www.test.com/abc/123/index.php

Note: abc is folder

RewriteEngine on
RewriteCond  %{REQUEST_FILENAME} !-f
RewriteCond  %{REQUEST_FILENAME} !-d
RewriteRule  ^(.*)/([0-9]+)/index.php $1/index.php?val=$2 [QSA,L]
  • 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-13T07:32:35+00:00Added an answer on June 13, 2026 at 7:32 am

    Your regular expression in the RewriteRule made no sense. In addition you cannot reference parts of the query string in a RewriteRule, so you have to additionally use a RewriteCond to capture the query arguments.

    Try this one:

    RewriteEngine on
    RewriteCond  %{REQUEST_FILENAME} !-f
    RewriteCond  %{REQUEST_FILENAME} !-d
    RewriteCond  %{QUERY_STRING} val=([0-9]+)
    RewriteRule  ^(.+)/index.php $1/%1/index.php [L]
    

    It is always a good idea to have apache itself help you with debugging expressions: use the logging feature: read the documentation for the two commands RewriteLog and RewriteLogLevel. They dump each step taken and allow to understand what is actually happening inside the algorithm.

    All information required is offered in the fine documentation. It really is worth working through…

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

Sidebar

Related Questions

I am beginner in PHP and Apache. I am trying to use URL Rewriting
As I am a beginner in the PHP programming field, I would like to
Beginner iOS dev here. I have a problem in my array. Im making an
Hey, a beginner's question here.... In order to learn PHP and SQl I have
I have developed a web application in Django and would like to go online
Once again a very beginner-ish question, but here I go: I would like to
Im a complete beginner with Apache re-writes. Im trying to get example.com/forum to be
I am going through the Tapestry beginner tutorial at: http://tapestry.apache.org/tapestry-tutorial.html I just downloaded the
Beginner in Android development. My code crashes. I have made a simple Java method
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later

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.