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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:11:23+00:00 2026-05-18T09:11:23+00:00

My url contains a broken link due to the http:// prefix not being added

  • 0

My url contains a broken link due to the http:// prefix not being added in places. How would I replace this using mod_rewrite:

http://website.com/www.websitelink.com

should go here:

http://www.websitelink.com
  • 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-18T09:11:24+00:00Added an answer on May 18, 2026 at 9:11 am
    RewriteRule ^www\.websitelink\.com$ http://www.websitelink.com/ [R=301,NC,L]
    

    In other words, if your path is /www.websitelink.com (^ is start of string,$ is end of string; in regular expressions, dots are one-character wildcards and have to be escaped)
    (and [NC] matching is not case sensitive – /WwW.webSiteLink.COM would match, too),

    [R=301] redirect with status “301 (Moved Permanently)”
    to http://www.websitelink.com/
    and [L] leave processing (no more rewrite rules are processed).

    Note that this will work regardless of the site’s domain (would work e.g. for http://website.com/www.websitelink.com and http://www.website.com/www.websitelink.com )

    If you want to match all the paths that end with your domain, drop the starting ^:

    RewriteRule www\.websitelink\.com$ http://www.websitelink.com/ [R=301,NC,L]
    

    and if you want to match even paths without www., make it optional:

    RewriteRule (www\.)?websitelink\.com$ http://www.websitelink.com/ [R=301,NC,L]
    

    As @Litso noted, this won’t match the path after the “domain-in-path”; this should match the trailing path:

    RewriteRule (www\.)?websitelink\.com/(.*)$ http://www.websitelink.com/$1 [R=301,NC,L]
    

    To match any subdomain:

    RewriteRule ([a-z0-9.-]+\.)?websitelink\.com/(.*)$ http://www.websitelink.com/$1 [R=301,NC,L]
    

    And to match any domain:

    RewriteRule ([a-z0-9.-]+\.)?([a-z0-9.-]+)\.com/(.*)$ http://www.$1.com/$2 [R=301,NC,L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For instance my current url is http://www.sample.com/check/?code=1 Web page under this url contains a
jQuery(.rfr-col-title).css(display, none); I would like to hide this class .rfr-col-title if the url contains
Currently, I'm using a strategy found on many blog posts. Basically, the URL contains
My URLconf contains this pattern: url(r'^accounts/logout/$','django.contrib.auth.views.logout', name=logout), And I've trying to reverse that in
How would I write a .htaccess redirect rule if the URL contains a certain
Using Smarty Tags I'd like to determine if an URL contains a word, something
In a previous post ( Don't show this if the url contains the following
When Urls are autogenerated using the Url.Action helper, if a page contains a line
How would you remove the last directory if the url contains three directories For
consider following url: http://sitename.com/School/Admin/PageViewer i have a subfolder in School named UserFiles that contains

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.