If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

URL rewrites

I have been to the apache site on the subject of URL rewriting and read and read until I am nearly blind and I still havent a clue.

The server I am on is an Apache 2 on a Linux install and it is a shared host.

The host provide a widgit to put in to play .htaccess and .htpasswd files to restrict access to folders. The host also confirms that the particular Apache engine is the 2.0 engine.

I want to take "ANY" request for .php and .db files in a folder called "data" to be rewritten to the site root so that the request serves up a new URL and the site loads.

http://my.website.com/data/{adbname}.db

where {adbname} is a random set of letters or numbers

I have tried looking at the REQUEST_URI to match ^/data/ or ^/data/*.\.php as well as ^data/[a-z0-9]+\.db or a straight forward ^\.php and ^\.db look for the extentions and then redirect.

Simply put, its still allowing download of the .db files stored in the folder. Something that I am trying to prevent.

I have lost count of the number of sites that profess to help and TBH, as a beginner in theis URL rewriting game, help is very very thin on the ground, thes sites are either "baby talk" or "Uber geek" and no happy medium nor do any of the sites so far give any practical examples of real working .htaccess.

Even trying examples, they are not working.

I have asked the host several times now and I think that they are getting fed up of me asking them to check the config for the server.

Any .htaccess & .htpasswd files written by the web host CGI program work fine. When I upload a file I have written... flat on its face.

Well this is completely retarded way of offering support to people, the "link" to the support forum does not go anywhere except the page I am currently viewing in FAQ's on the Apache site and trying to sign up to a mailing list for support... They don't have any support for .htaccess.

How is someone supposed to get this stuff running if both avenues of support are fruitless?

Seriously, can anyone see anything wrong with the following? Which I might add is taken right out of the Apachee site and modded for my needs.

the .htaccess which currently asks for a password login works fine, when I add this in its place, the access to the file is still allowed and it appears that it does not matter what I put, even forcing everything requested in to a index.php file within the same folder has no effect at all.

The %{REQUEST_URI} variable for the URL http://www.example.com/directory/fil...b&c=d#fragment would be "/directory/file.ext".
^ means "the beginning".
^\.db cannot match the REQUEST_URI because it means "begins with .db" and the REQUEST_URI always begins with a /.
The substitution part of the RewriteRule (the second part) should not be a regular expressions (^/index.php should be /index.php).

I have a few rules I want to put in place. I installed a CMS tool for a friend to use and TBH the security is a bit lax and I want to beef it up a bit and force people in to using the correct URL.

What the web stats are showing is that the URL for the edit page (which serves up the site as well) is being requested more than the site index page. the site is getting around 25,000 hits a month and I would like the requests to stop requesting the edit page URL and push them on to the site root.

Would this force any request for admin.php that does not arrive on edit. subdomain get rewritten to the site root?

%{REQUEST_URI} starts with a slash.
C(hain) is not a RewriteCond flag.
A RewriteRule matches a similar part of the URL to the value of REQUEST_URI. It does not include the HTTP_HOST (the (sub) domain name). In a .htaccess file it is the path relative to the directory that the .htaccess file is in. So if it's /abc/.htaccess and the URL is http://www.example.com/abc/def/ghi.jkl?mno=pqr the RewriteRule would match "def/ghi.jkl".

I am not getting the results I would expect. Links and other link dependent things fail like css & images fails to load as soon as you request the edit.yourdomain.tld/admin.php. Any suggestions on what to do about testing if the request is a real image regardless of the requesting URL?

The idea behind the logic is looking for specific subdomain and admin page request, if either fail the match, the URL is to be left untouched.