Forum Moderators: phranque
yes url rewrites are allowed on the server but what I dont understand is how putting in the URLs to test the rewriting, I end up on a website thats nothing to do with what I have.
What I mean is, were on a .org.uk tld but the rewriter for some reason is writing the URL to another site called cms.co.uk and path gets reversed to /admin//cms/ with a // between the admin and cms. The question is WT hell did the .co.uk bit come from and the fact I am going to a completely different site baffles me! So I will post the original code of what I put together and start again.
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/ [QSA,S=2]
# 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 ^(.*)/admin$ http://$1/cms/
# if we get here, its likely nothing matched, so do nothing to the URL
RewriteRule .* - [L]
What I have is to protect a URL by diverting normal requests for the admin side of things to the site root for the CMS in use while allowing an administrator subdomain to access the admin login side of things. The admin. subdomain will be a different name in the working script, this being used to make accessing the admin pages difficult. The admin url login log for those pages shows a very high number of access attempts considering I and 1 other person log in to that site, another site I login occasionally and that is currently being hammered. Think someone trying to brute force their way in, so I would like to add a layer of security. The big problem is that I am completely lost with URL rewriting, I tried the Apache site and that currently does not seem to be helping me much. Anyone here got any ideas on where or what I am missing or doing wrong?
[edited by: jdMorgan at 3:47 am (utc) on Feb. 1, 2010]
[edit reason] De-linked URLs in code. [/edit]
Please state *all* of the various subdomain and URL-path variations and their desired dispositions, e.g.
admin.example.com/cms/admin/ --> ?
admin.example.com/cms/admin/somefile.phd --> ?
admin.example.com/admin/ --> ?
admin.example.com/admin/somefile.phd --> ?
admin.example.com/<anything else but /cms or /admin --> ?
notadmin.example.com/cms/admin/ --> ?
notadmin.example.com/cms/admin/somefile.phd --> ?
notadmin.example.com/admin/ --> ?
notadmin.example.com//admin/somefile.phd --> ?
notadmin.example.com/<anything else but /cms or /admin --> ?
Also, instead of rewriting these bogus requests, have you considered simply returning a 403-Forbidden response? Or a zero-byte file?
I would give this requestor neither valid files nor any additional information, myself. Just a 403 and be done with it.
Jim
[size=3]Options +FollowSymLinks
Options -Indexes
RewriteEngine On[/size] [size=3]RewriteCond %{REQUEST_URI} ^/cms/admin$ [NC]
RewriteCond %{HTTP_HOST} ^admin\. [NC]
RewriteRule (.*) http: //$1/ [QSA,S=2][/size]
Options +FollowSymLinks -Indexes
RewriteEngine on
#
# If the subdomain is not "admin", redirect /cms/admin requests to the /cms directory root
RewriteCond %{HTTP_HOST} !^admin\.example\.com
RewriteRule ^cms/admin/ http://www.example.com/cms/? [R=301,L]
#
# - end -