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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:51:48+00:00 2026-06-12T07:51:48+00:00

I have the following code in my .htacess but it didn’t work right. Is

  • 0

I have the following code in my .htacess but it didn’t work right. Is it because mod-rewrite is no “on”, if so, how can i check?

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\$ $1.php [nc]

I wanted to rename my address, example:

http://www.abc.com -> http://www.abc.com

http://abc.com -> http://www.abc.com

http://www.abc.com/123.html -> http://www.abc.com/123

http://www.abc.com/12-12-12.html -> http://www.abc.com/12-12-12

http://subdomain.abc.com/123.html -> http://subdomain.abc.com/123

Basically removing the extension and ensuring that its www is intact.

Edited:

It was rewrote into

Options +FollowSymlinks
RewriteEngine on
RewriteCond % ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteRule ^(.*).php $1

but still not working

  • 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-12T07:51:49+00:00Added an answer on June 12, 2026 at 7:51 am

    Step 1.

    Change all of your links to have the .html removed from links. Make sure you have Multiviews turned off:

    Options -Multiviews
    

    Step 2.

    You need rules to redirect the browser when there is a www missing from the hostname:

    RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
    

    Step 3.

    You need rules to redirect the browser when a URL is requested with .html or .php with the extensions removed:

    RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ /([^\ ]+)\.(php|html?)
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ /%2 [L,R=301]
    

    Step 4.

    You need rules to internally rewrite the URI if the request was actually for a php or html file:

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.*)$ /$1.php [L]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.htm -f
    RewriteRule ^(.*)$ /$1.htm [L]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^(.*)$ /$1.html [L]
    

    .htaccess

    So all in all, you should have these rules in your htaccess (ditch any rules you may already have trying to solve this issue):

    # Make sure Multiviews is off
    Options -Multiviews
    
    # turn on rewrite engine
    RewriteEngine On
    
    # Redirect requests that are missing www and not a subdomain
    RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
    
    # Redirect if requests is for a .htm, .html, or .php
    RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ /([^\ ]+)\.(php|html?)
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ /%2 [L,R=301]
    
    # rewrite to the proper extension if such a file exists
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.*)$ /$1.php [L]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.htm -f
    RewriteRule ^(.*)$ /$1.htm [L]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^(.*)$ /$1.html [L]
    

    So altogether:

    • if browser URL address bar says: http://example.com/index.html it will be redirected to http://www.example.com/index
    • if browser URL address bar says: http://www.example.com/index it will be shown the content at http://www.example.com/index.html (or index.php if that exists). Address bar remains unchanged.
    • if browser URL address bar says: http://foo.example.com/images/image.png you will see the image at /images/image.png. Address bar remains unchanged.
    • if browser URL address bar says: http://foo.example.com/path/foo/bar.php it will be redirected to http://foo.example.com/path/foo/bar
    • if browser URL address bar says: http://foo.example.com/path/foo/bar it will be shown the content at http://foo.example.com/path/foo/bar.php. Address bar remains unchanged.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have used the following code in .htaccess Options +FollowSymlinks RewriteEngine On RewriteBase /
I have the following HTACCESS code: Options +FollowSymLinks RewriteEngine On RewriteBase / #RewriteCond %{REQUEST_URI}
I have the following code: RewriteEngine on #Options +FollowSymLinks RewriteCond %{HTTP_HOST} ^raal.co.il RewriteRule (.*)
I have following code in initialization im = imread('Image02.tif'); figure(); imagesc(im); colormap(gray); [hImage hfig
I have following code <div id=main> <div id=one> </div> <div id=two> </div> <div id=three>
I have following code for updating user's column public void UpdateLastModifiedDate(string username) { using
I have following code for loading image from url in xml parsing endElement method
I have following code for inserting data into database using PDO. It inserts data
I have following code. ASPX Page <a href=AnyASPXPageOfWebsite.aspx onclick=javascript:CallJQuery(); > Set Price </a> JS
I have following code that I am compiling in a .NET 4.0 project namespace

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.