I'd like to change the page that is shown when a directory doesn't have an index.php/html page.
I made a php page that I'd like to use, but I don't know how to set it as a default. I don't want to copy the file into every single directory.
Is this even possible?
You can configure this is the httpd.conf under the DirectoryListings setting
http://wiki.apache.org/httpd/DirectoryListings
DirectoryIndex yourpage.php index.html index.htm index.php welcome.html
Related
After moving the rootDirectory of apache2 from
/var/www/html
to
/var/www/html/MyFolder
because I didn't want my website to be "www.website.de/MyFolder"
but now I have to type in "www.website.de/index.php" (that works)
What do I have to change so I can just type in "www.website.de" and the index.php is displayed automatically
I didn't change much. Only the rootDirectory 000-default.conf.
Add this:
DirectoryIndex index.php index.html index.htm
Or just:
DirectoryIndex index.php
If you don't care about index.html and index.htm being possible alternatives.
This tells Apache which files should be served from a directory when no file is specified, in order of priority.
Perhaps put it in a .htaccess file in MyFolder.
I had changed the DNS Nameservers recently but my browser is still redirecting me to the old DNS servers. I found that out because on my phone everything is working perfectly.
I tried everything - from clearing browser cache to ipconfig /flushdns but nothing worked until now - maybe somebody has an idea how I can fix this problem on my machine?
Here is the folder layout.
/outside is not normally accessible anywhere on example.com
/public_html is the folder for http://example.com
How can I use Apache's htaccess to make the url http://example.com/outside/ to show content from the folder /outside?
Thanks!
How can I use Apache's htaccess to make the url http://example.com/outside/ to show content from the folder /outside?
You can't. As far as I have found out, Apache prevents directives in .htaccess files linking to locations outside the current web root.
You would have to do this in the central configuration:
Alias /outside /path/to/your/outside
You may be luckier with a symlink if you can turn FollowSymLinks on.
I am using MAMP to host a website.
I have index.html and index.php both inside a folder.
How can I make web server open index.html instead of index.php
THanks.
Make sure you configure the right order of DirectoryIndex.
I have not done any web dev before. I got my Apache server running on mac OS X, and set up a virtual host at /Users/dan/webapps. So, when I go to http://localhost/ in my browser, my index.html in the webapps folder shows up, as expected.
I then created Users/dan/webapps/temp/ folder, and put a flash app in there, let's call it "test.html", along with the required "test.swf". I restart the server. However, when i put http://localhost/temp into my browser, I get File Not Found. How do I make the browser able to go to that directory, and when it goes there, have it start test.html. I am using Safari. Thanks.
you should type: http://localhost/temp/test.html
a full path to your page,
Or you can change the name of your page from test.html to index.html and it would be loaded when you enter http://localhost/temp/, since the default DirectoryIndex is index.htm or index.html
Create a .htaccess file in Users/dan/webapps/temp/, and add the line:
DirectoryIndex test.html
This will make apache look for test.html when someone accesses the directory. Make sure permissions/ownership allows your webserver to read this file.
So this is my directory structure
/
/test
index.php
blah.php
blah.php
So in /test/index.php I have a link such as this
Link
but I want it to link to /test/blah.php, not the blah.php in the root directory. Basically, I want to set a local document root. Is this possible to set this using .htaccess or in the httpd.conf?
If an a tag on /test/index.php has its href set to /blah.php, then it's the browser that's interpreting that as pointing to a file in the document root. So you can't achieve what you want without changing the way you're generating the href attribute.
You have a couple of options for this:
You can omit the forward slash to generate links relative to the current URL instead of the document root. A link in /test/index.php pointing to blah.php will be interpreted as /test/blah.php.
You can write some custom code to generate your links. You could have a function my_special_link ($link) that takes in blah.php and prepends the current file's directory, for example.
Add this to your httpd.conf or better yet put it in a virtualhost directory
NameVirtualHost *:80
<VirtualHost *:80>
ServerName blah.localhost
DocumentRoot C:\web\test
</VirtualHost>
In WINDOWS\System\system32\etc\bin or somewhere ( LOOK for 'hosts' file ), edit hosts file so it has
127.0.0.1 blah.localhost
Restart apache and go to blah.localhost in the browser.