I have been trying to do a couple of things using .htaccess for a while, but have not been able to figure them out.
First, I would like a file to be accessible by no one EXCEPT the server. For example, if I have a page using AJAX to display "main.html" on the same page, I don't want anyone to be able to visit http://example.com/main.html to just view it, but I still want the server to be able to access it and use AJAX to display it on the same page.
I think "server" is the term I'm looking for, at least. This is what I've tried:
Second, I want to use .htaccess and mod_rewrite to direct visitors that try to go to a short URL to a longer URL. For example, if my visitors go to http://example.com/dir, I want them to be redirected to http://example.com/longer/dir WITHOUT changing what they see in the address bar.
I did this before in a previous site design, where example.com/someplace directed them to example.com/index.php?p1=someplace, or something like that, and the text in the address bar did not change; it stayed at example.com/someplace.
I know how to direct the user to another URL AND have the text in the address bar change, but I don't want the text in the address bar to change.
Any ideas on either of these issues?
Thanks!
Blake
First, I would like a file to be accessible by no one EXCEPT the server. For example, if I have a page using AJAX to display "main.html" on the same page, I don't want anyone to be able to visit http://example.com/main.html to just view it, but I still want the server to be able to access it and use AJAX to display it on the same page.
I think "server" is the term I'm looking for, at least. This is what I've tried:
Code:
<Files "main.html">
deny from all
allow from (my server's IP address here, which I found using PHP: "echo $_SERVER['SERVER_ADDR']")
</Files>
Second, I want to use .htaccess and mod_rewrite to direct visitors that try to go to a short URL to a longer URL. For example, if my visitors go to http://example.com/dir, I want them to be redirected to http://example.com/longer/dir WITHOUT changing what they see in the address bar.
I did this before in a previous site design, where example.com/someplace directed them to example.com/index.php?p1=someplace, or something like that, and the text in the address bar did not change; it stayed at example.com/someplace.
I know how to direct the user to another URL AND have the text in the address bar change, but I don't want the text in the address bar to change.
Any ideas on either of these issues?
Thanks!
Blake