JunkDrawStuff
01-30-2010, 08:03 AM
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
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.
I have very limited understanding of URL rewrite and try this
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.