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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:01:23+00:00 2026-05-28T16:01:23+00:00

I have a site where I am trying to change the urls using mod_rewrite

  • 0

I have a site where I am trying to change the urls using mod_rewrite from:

/directory/filename.php to directory/filename/

/directory/filename.php?id=7 to directory/filename/7/

/directory/filename.php?id=7&file_id=1 to directory/filename/7/1/

I am not able to work out the regular expressions to use for these pages though. Here is the entire .htaccess file:

RewriteEngine On    # Turn on the rewriting engine

RewriteRule  ^(.*)/?$ /directory/$1 [L] #Rewrite a page without $_GET variables
RewriteRule  ^([^/]+)/([0-9]+)/?$ /directory/$1?id=$2 [L] #Rewrite a page with 1 $_GET variables
RewriteRule  ^([^/]+)/([0-9]+)/([0-9]+)/?$ /directory/$1?id=$2&file_id=$3 [L] #Rewrite a page with 2 $_GET 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-05-28T16:01:24+00:00Added an answer on May 28, 2026 at 4:01 pm

    If the .htaccess is in the directory folder then the directory/ path prefix will be stripped for you and you do not need to bother about it in the rewrite rules.

    You could use something like:

    RewriteEngine On    # Turn on the rewriting engine
    
    RewriteRule  ^([^/.]+)/?$ $1.php [L] # rewrite without query string parameters
    RewriteRule  ^([^/.]+)/(\d+)/?$ $1.php?id=$2 [L] # one parameter
    RewriteRule  ^([^/.]+)/(\d+)/(\d+)/?$ $1.php?id=$2&file_id=$3 [L] # two parameters
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to change a site's home directory using powershell. This is what I
I'm trying to return a custom 404 page using IIS6. (I have a site
I have been trying to parse the bottom table on this site using different
I am trying to setup a mod rewrite rule to change urls like: http://www.site.com/play/4435
I have a site I'm trying to build and I've hit one little snag
I'm trying to have a site set up so when the page loads there
I have a site where I am trying to implement a jQuery UI based
i have a wordpress site and i am trying to add a phpbb3 forum
I have a web site hosted on IIS with windows authentication. I am trying
I have developed a site with ASP.NET MVC 1, and now I'm trying 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.