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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:28:35+00:00 2026-05-12T05:28:35+00:00

I am attempting clean useful URLs using mod_rewrite. I am sure this is a

  • 0

I am attempting clean useful URLs using mod_rewrite. I am sure this is a common question but I am not so hot with mod_rewrite:

I have this URL: http://mysite.com/user.php?user=fatcatmat&sort=popularv

I want to be able to rewrite it like this:

http://mysite.com/user/user/fatcatmat/sort/popularv
(Is there a way to remove duplicates in a URL?)

I think I have managed to do the removal of the PHP extension.

RewriteRule ^(.*)\$ $1.php [nc]

Is the above correct?

For the separate pages, I would have something like this.

RewriteRule ^/?user(/)?$ user.php

Main Question: Its a bit tedious to do all the above but is there a MEGA rewrite rule that will just place “/” in between variables and their values and remove the .php extension from all pages?

Thank you for any help.

  • 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-12T05:28:36+00:00Added an answer on May 12, 2026 at 5:28 am

    Try these rules:

    RewriteCond %{THE_REQUEST} ^[A-Z]+\ (/[^/?\s]+)+\.php[?/\s]
    RewriteCond %{QUERY_STRING} ^([^/&=]+)=([^/&]+)(&([^&].*))?$
    RewriteRule \.php$ ?%4 [N,E=PATH:%{ENV:PATH}/%1/%2]
    RewriteCond %{ENV:PATH} ^/
    RewriteRule \.php$ %{ENV:PATH} [L,R=301]
    
    RewriteRule ^(.*)/([^/]+)/([^/]+)$ $1?$2=$3 [N,QSA]
    RewriteRule ^([^/]+)/([^/]+)$ $1.php?$1=$2 [L,QSA]
    

    But it would be a lot easier to do that with PHP: Check what URI path has been requested (see $_SERVER['REQUEST_URI']) and redirect if necessary (see header function).

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

Sidebar

Related Questions

I am attempting to clean out a table but not get rid of the
I'm attempting to use mod_rewrite to clean up the URL's to a flash video
Using ANT , how can i make sure that directory exists before attempting to
I'm attempting to clean up data in this (old) spreadsheet and need to remove
I'm not sure I understand the error messages I'm getting while attempting to deploy
I am attempting to add embedded documents. I know this syntax is wrong but
I am attempting to clean up some dodgy xml attributes with Regular expressions. My
Attempting to build a C# NPAPI plugin I have found a tutorial which describes
Attempting to get Spring internationalization working. I have used classpath:messages basename, created .properties files
Attempting to use the data series from this example no longer passes the JSONLint

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.