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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:02:51+00:00 2026-05-11T11:02:51+00:00

This is what I’m trying to do with the htaccess: Force remove the www

  • 0

This is what I’m trying to do with the htaccess:

  • Force remove the www from the url
  • Be able to use http://website.com/site/ to get to http://website.com/site.php, and force the last slash even if it’s not added by the user. So if i write http://website.com/site it will be converted to http://website.com/site/
  • Also translate http://website.com/download.php?=file.exe to http://website.com/download/file.exe. Also http://website.com/news.php?article=43532 into http://website.com/news/article/43532

The htaccess code should not have to contain the domain it’s going to be used on.

I’ve been trying to find something like this on the net for ages, but I only find each part and they don’t work together.

Can anyone help me with this?

  • 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. 2026-05-11T11:02:52+00:00Added an answer on May 11, 2026 at 11:02 am

    Ok, here’s my try. Note that the Apache manual is quite good. I differ from benlumley on the ‘site’ portion. Also, you may want to replace ([0-9]+) with simply (.+) if your news article names are not all numeric.

    # Ensure that rewriting is enabled RewriteEngine on  # First strip the www as benlumley did RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L]  # Then convert /site to /site/, reflecting the change in the address bar RewriteRule ^([^/.]+)$ /$1/ [R=301,L] # Finally map /site/ to /site.php RewriteRule ^([^/.]+)/$ /$1.php  # Finally, fix download and news as benlumley did RewriteRule ^download/(.+)$ /download.php?file=$1 RewriteRule ^news/article/([0-9]+)$ /news.php?article=$1 

    EDIT: Fixed copy/paste error for the ‘strip www’ part.

    NOTE: Any <link href='...'> or <script src='...'> tags that you have will now need to be specified as absolute paths because you have effectively changed the directory that the page appears to be served from.

    E.g. consider the following line from your blog.php:

    <link rel='stylesheet' type='text/css' href='style.css'> 

    Previously the browser saw http://site/blog.php and thus tried to retrieve http://site/style.css, which worked.

    Now that the browser instead sees http://site/blog/ the relative URL above is interpreted as http://site/blog/style.css, which does not exist. As such, the href needs to be changed as:

    <link rel='stylesheet' type='text/css' href='/style.css'> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first time using Magento. I upgraded this site from 1.4.1.1 to
I am trying to understand how to use SyndicationItem to display feed which is
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
This is an example of the code am using. I use a modified version
This is as close as I've gotten to successfully populating an expandable listview from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This is mostly a philosophical question about the best way to interpret the HTTP
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

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.