12-11-2007, 10:22 AM | #1 (permalink) |
Lover - Protector - Teacher
Location: Seattle, WA
|
Apache, URLs and mod_rewrite
I'm trying to set up my remote hosted website (Apache) so that the URLs is useful to users and Search Engines alike, but here's my problem. myURL.com below is just an example.
I own http://www.MyURL.com (and by extension, http://myURL.com). In the root of my site (with .htacess, robots.txt, etc) is a file called index.html. I don't want this to be what they see when they go to my website. * If someone types in www.MyURL.com, Apache fetches index.html. How does it know to select this one? No filename was given, only a directory name. * What I'd like it to fetch is in a subdirectory from the root, /flatpress/. It's index.php. If I manually type www.MyURL.com/flatpress, it knows to grab index.php. Again, how does it know? I imagine it's an Apache config file I don't have access to. I'd like http://www.MyURL.com/ and http://myURL.com/ to fetch and display the file at /flatpress/index.php while still showing the URL http://myURL.com in the browser. I've tried to use RewriteEngine (mod_rewrite) to accomplish this, but it fails miserably. Help? And now that I look at it, TFP does it exactly like I want. Typing http://tfproject.org/ is the same as http://www.tfproject.org, and both redirect to http://www.tfproject.org/tfp without showing a filename like forum.php or whatever it'd be.
__________________
"I'm typing on a computer of science, which is being sent by science wires to a little science server where you can access it. I'm not typing on a computer of philosophy or religion or whatever other thing you think can be used to understand the universe because they're a poor substitute in the role of understanding the universe which exists independent from ourselves." - Willravel Last edited by Jinn; 12-11-2007 at 10:27 AM.. Reason: Automerged Doublepost |
12-11-2007, 11:17 AM | #2 (permalink) |
Darth Papa
Location: Yonder
|
There's an apache directive called DirectoryIndex, where you set the default page to load. It defaults to index.html, which is how Apache knows that--although it could be anything. But you can't tell it to look inside a subdirectory.
When I set up a blog site for one of my big clients with a bunch of blogs, I extract the Wordpress tarball, which puts the goods in /wordpress. I move everything from that directory out into the root of the site. I'd actually recommend you do the same--move the contents of flatpress/ to /. That's going to be the cleanest and lest-configuration way to do this. mod_rewrite is a disaster--and I work with it frequently. I really pity somebody trying to figure it out for the first time. You could also change the Directory of your virtual host to point at the flatpress directory, if you have access to the machine's apache config files. You can't do that from .htaccess. |
12-11-2007, 02:56 PM | #3 (permalink) |
Lover - Protector - Teacher
Location: Seattle, WA
|
HAHAHA I can't believe I didn't think to just move the contents down a layer on the filesystem. Thanks a ton, Ratbastid.
__________________
"I'm typing on a computer of science, which is being sent by science wires to a little science server where you can access it. I'm not typing on a computer of philosophy or religion or whatever other thing you think can be used to understand the universe because they're a poor substitute in the role of understanding the universe which exists independent from ourselves." - Willravel |
Tags |
apache, modrewrite, urls |
|
|