I have recently reinstalled MacOSX, and at some point (without realizing it) I made it so that a directory without index.html would try instead to run index.php. This has since stopped working. My localhost runs .php files fine; it just doesn't do so unless you specifically tell it to.
There are lots of htaccess guides online but I can't actually find one that tells me how to solve this problem :s
I believe it's the "DirectoryIndex index.php" directive in .htaccess that will do the trick.
Related
I was just asked to work on a terrible site that the client is running off IIS. I can't make changes to the live server so I attempted to install the site on my testing server running Apache.
The site's homepage is up and running but I cannot navigate to any subdirectories. The nav menu has links like /about-us/ -- however, there is no index.php file in the about-us directory. Instead there is a file named about-us.php.
If I was getting paid to fix the site up I would do the work to rename the files and/or links, but for now I just want to get this thing running so I can make my CSS and content edits and be done with it. I assume there is some easier way (using htaccess?) to dynamically tell Apache that, when directed to a subdirectory, look for /foo/foo.php instead of /foo/index.php -- right now all I get is a directory listing or permission denied if I turn indexing off.
I've been Googling around but can't find anything that looks like the same problem -- can one of you rewrite gurus please point me in the right direction?
The best approach for you is to set the appropiate DirectoryIndex for each directory as in:
<Directory /path/to/about-us>
DirectoryIndex about-us.php
</Directory>
You can also define a single "controller" in case there is no index page found, this is done like:
FallBackResource /index.php
I'm using xampp and tried to put my yii folder and the webapp folder separate from the htdocs directory. I've followed the instructions from here:
http://el.web.id/how-to-add-virtual-directory-alias-on-apache-xampp-165
I was able to run the main page all right, but the other pages just return a not found status. May I know how to fix this? I'm not even sure if the main problem comes from Apache or from Yii. Thanks a lot.
Oh, I get it now. We'd just need to add a rewritebase on the .htaccess file that matches the alias.
RewriteBase /aliasfolder
This is for reference purposes.
I was doing some tests with mod_rewrite in my wamp environment.
I tested a simple rule that I put at the root of one of my websites and asked it to redirect any request ending with index.php to localhost (there is no sense to it, just wanted to check the rule)
It worked, but after, any change I'd made to my .htaccess file rule was not reflected.
After a while I just decided to delete the .htaccess... well it's still doing redirection! I just don't understand it. Does Apache cache the rules or something (restarting services trough wamp menu didn't change anything)
(Don't ask for the exact rule I used, since I deleted the file, I don't think it's relevant anyway)
.htaccess files are processed each time a request comes through. It is possible that your browser cached the request being forwarded. Did you try it with httpfox or anything to see what the headers said?
Have you tried deleting the browser cache?
I want to run Zend site under an alias on WAMP. I am able to setup alias, but when I copy a working Zend site there and modify .htaccess to include "RewriteBase /alias", it still does not work. Error messages tell me that controller not found. Mainly this is what happen:
I have: server.com/alias
With Zend file structure inside (application, public, etc).
alias points to c:/wamp/apps/alias
Where Zend structure is stored.
.htaccess has line: RewriteBase /alias
As I understand server.com/alias should act as root folder, but it's not. If I run Zend site under root folder everything works fine then.
Can you tell me how to properly set up alias to run Zend site on WAMP? Thank you.
I think the problem is that your rewrite rules doesn't work well. take a look at this.
Because of weird security policies of my hosting provider I have to define my rewrite rules in /etc/apache2/conf.d/examplesite.conf instead of writing them on an .htaccess on the www folder of that site.
What I'm trying to do is setup a Wordpress Mu server (http://mu.wordpress.org/forums/topic/17349 ) and so far its working on a 50%.
The main blog loads perfectly but other sub blogs (located for example at www.example.com/blog2 ) don't.
I'm guessing the problem is that the rewrite rules behave differently when declared at .conf files for each virtual host instead of using .htaccess files.
Has anybody else had this problem? How can you fix it?
This doesn't sound like a rewrite problem to me but maybe it is. You don't say what the error is when you try to load one of the sub blogs. Perhaps posting up what your rewrite rule is would be helpful. Also would you be able to set up a scenario where you did them in .htaccess files on a localhost or something and seeing if there was a difference?
If pretty permalinks work, then mod_rewrite is enabled, and rewriting URLs to WordPress successfully.
If this is the case, then it's a problem with your MU install.
Did you choose paths over sub-domains during the MU install? If you didn't, but then later switched, that's where the problem is - are you in a position to fresh install?