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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:10:27+00:00 2026-06-13T05:10:27+00:00

I have some question to ask about rewrite url in php. 1- www.test.com/index.php?name=123 to

  • 0

I have some question to ask about rewrite url in php.

1- http://www.test.com/index.php?name=123 to http://www.test.com/123

2- http://www.test.com/folder1/index.php?name=123 to http://www.test.com/folder1/123/index.php

Hereabout my coding on number 1 but i don’t know how to rewrite number 2 combination with number 1:

RewriteEngine on
RewriteCond  %{REQUEST_FILENAME} !-f
RewriteCond  %{REQUEST_FILENAME} !-d
RewriteRule  ^(.*)$ index.php?usname=$1 [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-13T05:10:30+00:00Added an answer on June 13, 2026 at 5:10 am

    When you say “rewrite url in php”, I assume that “in php” refers to the language of the application, not the rewrite/redirect method — because your example code consists of Apache directives.

    The rules below will change URLs in the form test.com/folder1/index.php?name=123 into a “pretty” URL of the form test.com/folder1/123 (I removed the ‘index.php’ to be even more user-friendly).

    1. Redirect the ugly query URL so users always see the “pretty” URL

      RewriteCond  %{QUERY_STRING} \bname=([^&]+)
      RewriteRule  ^/?folder1/index\.php$ /folder1/%1 [R=302]
      
    2. Tell the server how to interpret the pretty URL

      RewriteRule  ^/?folder1/([^\/]+)(/index\.php)?$ /folder1/index.php?name=$1 [L]
      

    NOTE:
    The first rule above uses a 302 (temporary) redirect, so your browser doesn’t “memorize” the redirect rule while you’re testing and tweaking them. If you care about SEO, change the [R=302] to [R=301], which is a permanent redirect.

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

Sidebar

Related Questions

i need to ask some question about crystal report. I have successfully run crystal
I have a question to ask about notifications. After some hours to learn how
I have some question about WH_MOUSE. From what I've read, by putting the hook
So, i have some question about xml Documents in Java. Can i get all
I have some questions, maybe stupid question. I have this url: http://flibusta.net/opds/opensearch?searchTerm=Тол&searchType=books and I
I have a question about reflection I am trying to have some kind of
Quick question about include/requre_once . I have some code that is common to a
I have never before rewritten a URL except for removing the index.php part of
I have some question about using queues and threads. I already made researches, but
I have some deep question about OOP architecture. What is a proper way 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.