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

  • Home
  • SEARCH
  • 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 7748423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:46:55+00:00 2026-06-01T10:46:55+00:00

I have this scenario where I would like to redirect my domains using the

  • 0

I have this scenario where I would like to redirect my domains using the following scenario. Can you please advice if this can be achieved using RewriteRule in Apache?

I would like to redirect any calls made using http://www.domainname.com/url to redirect to http://domainname.com/url.

I was able to achieve the above using the following rewrite rule

# BEGIN WithoutWWW
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.domainname\.com$ [NC]
RewriteRule ^(.*)$ http://domainname.com/$1 [R=301,L]
# END WithoutWWW

If anyone tries to visit just http://www.domainname.com or http://domainname.com, I would like them to redirect to http://dname.com

How can I achieve this rule using RewriteRule in Apache?
I’m also using PHP, so a solution using PHP would be valid too.

  • 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-01T10:46:56+00:00Added an answer on June 1, 2026 at 10:46 am

    Here is your combined .htaccess with your existing and new code:

    RewriteEngine on
    
    # redirect domainname.com/ or www.domainname.com/ to dname.com/
    RewriteCond %{HTTP_HOST} ^(www\.)?domainname\.com$ [NC]
    RewriteRule ^$ http://dname.com [R=301,L]
    
    # append www to domainname.com    
    RewriteCond %{HTTP_HOST} ^www\.domainname\.com$ [NC]
    RewriteRule ^ http://domainname.com%{REQUEST_URI} [R=301,L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple form for this scenario written in razor/webmatrix. I would like
I have a scenario where I would like to redirect the user while he
I have this scenario. I want group on Country and Category. A store can
Please Consider this scenario: We have a base class called clsMain : class clsMain
So i basically have this ListView and i would like to press Tab and
Which threading model is best for this scenario: I have a process can take
I have this scenario well, i'll let the model explain. public class ScheduleMonthlyPerDayModel {
So I have this scenario <div id=editor contenteditable=true> <div id=list>Hello</div> </div> I want to
In my app, I have this scenario where I need to post an object
Imagine this scenario: You have a desktop and a laptop. The desktop has a

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.