URL rewrite from www.domain.com/sudirectory to http://domain.com/subdirectory

Posted by chrizzbee on Pro Webmasters See other posts from Pro Webmasters or by chrizzbee
Published on 2013-11-19T17:32:30Z Indexed on 2014/08/20 22:34 UTC
Read the original article Hit count: 383

Filed under:
|

I need a solution for the following problem:

I use a CMS and want the backend only be available at http://domain.com/backend and not at http://www.domain.com/backend.

How do I have to change my .htaccess file to achieve this? I already have a rewrite rule from HTTP (non-www) to www.

Here's what I currently have in my .htaccess file:

  ##
  # Uncomment the following lines to add "www." to the domain:
  #
RewriteCond %{HTTP_HOST} ^shaba-baden\.ch$ [NC]
RewriteRule (.*) http://www.shaba-baden.ch/$1 [R=301,L]
  #
  # Uncomment the following lines to remove "www." from the domain:
  #
  #   RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
  #   RewriteRule (.*) http://example.com/$1 [R=301,L]
  #
  # Make sure to replace "example.com" with your domain name.
  ##

So, the first bit is the redirect from HTTP to www. It works on the domain part of the URL. As explained, I need a rewrite rule from the backend login at http://www.shaba-baden.ch/contao to http://shaba-baden.ch/contao

© Pro Webmasters or respective owner

Related posts about mod-rewrite

Related posts about url-rewriting