www.webdeveloper.com
Results 1 to 4 of 4

Thread: Onion Layer

  1. #1
    Join Date
    Jan 2010
    Location
    Great Britian
    Posts
    21

    Onion Layer

    I want to add a layer of security to an admin login link on a server, well three domains so I want to write one .htaccess file that I can just upload to each server to deal with this problem.

    I have very limited understanding of URL rewrite and try this
    Code:
    Options +FollowSymLinks
    Options -Indexes
    RewriteEngine On
    
    # We need to test the URL to see if the request is for the admin URL
    # 1. if the URL has /cms/admin/ in the REQUEST_URI and
    # 2. if the DOMAIN has admin. as the subdomain, we issue the admin pages
    RewriteCond %{REQUEST_URI} ^/cms/admin/$ [NC]
    RewriteCond %{HTTP_HOST} ^admin\.(.*)/$ [NC]
    RewriteRule .* http://$1/cms/admin/ [L]
    
    # We need to test the URL to see if the request is for the admin URL witout the prefix
    # 1. if the URL has /cms/admin/ in the REQUEST_URI and
    # 2. if the DOMAIN has not got admin. as the subdomain, we issue the site root pages
    RewriteCond %{REQUEST_URI} ^/cms/admin/$ [NC]
    RewriteCond %{HTTP_HOST} !^admin\.(.*)/$ [NC]
    RewriteRule .* http://$1/cms/ [L]
    
    # if we get here, its likely nothing matched, so do nothing to the URL
    RewriteRule .* - [L]
    Problem is that the redirect try directing to http://cms/ which is invalid.

    What I want to do is use the URL admin.thedomainname.com/cms/admin/ to allow access to the page for login but thedomain.com/cms/admin/ to push access to the site root page.

    The aim being that I can change the admin to whatever I want so that I could use systemadmin.thedom..... or pepperonichees.thedom... or whatever I alter admin to in the htaccess file to stop people trying to login to the CMS that I am using that is installed on the server in the /cms/ folder.

    I already had help with redirection for site root to /cms/ folder, I now need to stop the thousands of hits on the /cms/admin/

    Can someone tell me what I am doing wrong?

    Thank you.

  2. #2
    Join Date
    Dec 2005
    Posts
    2,984
    You're not actually 'matching' anything so $1 is nothing

    Replace these lines

    Code:
    RewriteRule .* http://$1/cms/admin/ [L]
    
    ...
    
    
    RewriteRule .* http://$1/cms/ [L]
    with these:

    Code:
    RewriteRule (.*) http://$1/cms/admin/ [L]
    
    ...
    
    
    RewriteRule (.*) http://$1/cms/ [L]

  3. #3
    Join Date
    Jan 2010
    Location
    Great Britian
    Posts
    21
    Really confused now... I get

    http://www.cms.co.uk/admin//cms/

    When I test a url that is http://somedomain.org/cms/admin/

    Where did the .co.uk bit come from?

  4. #4
    Join Date
    Jan 2010
    Location
    Great Britian
    Posts
    21
    So the $1 only works on the line that is is on then?

    I though the back reference was for storage and later use.

    So how does the %1 thing work then.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles