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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:08:18+00:00 2026-05-20T01:08:18+00:00

I have a site with a set of old .html and .php pages that

  • 0

I have a site with a set of old .html and .php pages that have been put into a CMS.

Currently in the .htaccess file there are about 30 mod_alias redirects in the following form:

redirect 301 /oldpage1.html http://www.example.com/newpage1.php
redirect 301 /oldpage2.php http://www.example.com/newpage2.php
redirect 301 /oldpage3.php http://www.example.com/newpage3.php

But we want to use mod_rewrite to have pretty URLs in our CMS, which will take the form http://www.example.com/pagename.php, so also have the following:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1

At the moment both are being applied together, which results in:

http://www.example.com/newpage1.php?page=oldpage1.html

How can I apply the rewrite rule only when no match has been made by the mod_alias redirect 301 statements, so that the following occurs:

http://www.example.com/oldpage1.html -> redirects to ->
http://www.example.com/newpage1.php -> which is treated as ->
http://www.example.com/index.php?page=/newpage1.php

Any hints would be very much appreciated? Thanks.

  • 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-20T01:08:19+00:00Added an answer on May 20, 2026 at 1:08 am

    I found the answer in a great explanation of mod_rewrite and mod_alias

    The problem is that mod_rewrite always occurs before mod_alias, regardless of the order the are placed in .htaccess. This is the reverse of the order required for this situation.

    The trick is to use RewriteRule [R=301] instead of redirect 301, and hence use mod_rewrite for everything instead of mixing it with mod_alias.

    Full solution is as follows:

    RewriteEngine on
    RewriteBase /
    
    RewriteRule ^oldpage1.html /newpage1.php [R=301,L]
    RewriteRule ^oldpage2.php /newpage2.php [R=301,L]
    RewriteRule ^oldpage3.php /newpage3.php [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$ index.php?page=$1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have a site that is set up using a masterpage and a
I have been developing our php based site on a development box that was
I have an old .net 2005 web site that has some asp pages and
For example I have site http://localhost/site In IIS I set that 404 error causes
I have a fairly complex set of rewrite rules to give my site pages
I have a simple update set php sql function on my site where I
I have a javascript widget that can be inserted on an a plain-old html
I have a site I'm building in PHP, and have a page that loads
I currently have a community site that I run that is made up of
I have a PHP based site with dynamic pages , such as /page.php?ID=1. The

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.