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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:46:16+00:00 2026-05-25T06:46:16+00:00

I have a simple mod_rewrite system set up on my site which basically converts

  • 0

I have a simple mod_rewrite system set up on my site which basically converts

http://site.com/file -> http://site.com/file.php

Here’s the .htaccess file

Options -MultiViews
RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.site.com
RewriteRule ^(.*)$ http://site.com/$1 [R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]+)/?$ http://site.com/$1.php [L]

This was working for a long time and then a couple of days ago I realized that while the RewriteRule was working, it was actually changing my URL in the status bar.

For instance, it would redirect /photos to /photos.php, but it would also change the URL to show the .php. This has never happened before and I’m not sure what happened to trigger the change.

Any ideas?

  • 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-25T06:46:16+00:00Added an answer on May 25, 2026 at 6:46 am

    The first rewrite rule needs the [L] flag. From the mod_rewrite documentation for the [R] flag:

    You will almost always want to use [R] in conjunction with [L] (that is, use [R,L]) because on its own, the [R] flag prepends http://thishost[:thisport] to the URI, but then passes this on to the next rule in the ruleset, which can often result in ‘Invalid URI in request’ warnings.

    In this case, you don’t get a warning, but appending the “.php” extension happens before issuing the redirect rather than when the second, redirected request comes in.

    Also, remove the scheme and domain name from the substitution in the second rewrite rule. A full URL can cause an implicit redirect. From the documentation for RewriteRule:

    The Substitution of a
    rewrite rule is the string that replaces the original URL-path that
    was matched by Pattern. The Substitution may
    be a:

    […]

    Absolute URL
    If an absolute URL is specified,
    mod_rewrite checks to see whether the
    hostname matches the current host. If it does, the scheme and
    hostname are stripped out and the resulting path is treated as
    a URL-path. Otherwise, an external redirect is performed for
    the given URL. To force an external redirect back to the
    current host, see the [R] flag below.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple SSIS package which reads data from flat file and insert into
I just wanted to do a simple thing with mod_rewrite. I have a site
So, I have at site where I want pages such as; www.example.com/shop/index.php (or any
I have already configured my apache(mod_rewrite,alias,allowOverride), and I am trying to rewrite http://localhost/b33m/view_blog_details.php?post_id=4 To
I have the following mod_rewrite rule: RewriteRule ^home/ home.php [L] Fairly simple. When I
I have a simple mod_rewrite question. What do I need to write in the
I have simple form. <form target=_blank action=somescript.php method=Post id=simpleForm> <input type=hidden name=url value=http://...> <input
I have simple SSIS package in which On Error event handler I have created
I'm trying to add a simple 301 rule to the .htaccess file of a
for some days now I have been trying to make a simple mod_rewrite rule

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.