Apache and Rewrite Module
I created a file .htaccess in the /var/www directory. The rights are "root root --wxrwxrwxr".
The content of the file is:
Options +FollowSymlinks
RewriteEngine on
RewriteLogLevel 3
RewriteLog "/var/log/apache2/rewrite.log"
RewriteRule ^(.*?)$ testphp.php
When I call the page phpinfo.php, I've got: Loaded Modules ... mod_rewrite ... Th开发者_StackOverflowerefore, the modules is loaded.
After each modification, I restared the server manually with sudo /etc/init.d/apache2 restart
.
The error.log gives
Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.2 with Suhosin-Patch configured -- resuming normal operations
When I call a page anyone.htm or anyone.php, the rewrite.log does contain nothing and the real page is called. If I understand, the page anyone.php
should be replaced by testphp.php
Did I make siomething wrong?
Thanks
If i were a web server, i'd ignore any config file that was world writable, for stability and security's sakes. I know there's places in Apache that do exactly that; i forget whether .htaccess processing is one of those places, but i'd assume/hope it is.
Thanks for your help
Here is what I made to get the Apache2 server running with the Rewrite Rule:
- I re-installed the server from a new hard disk
- I activated the Rewrite with 'sudo a2enmod rewrite'
I created the file '.htaccess' with the rules:
RewriteEngine On RewriteRules ^(.*)$ test.php
In the "/etc/apache2/sites-available/default", I added in the directory/
AllowOverride all
Order deny,allow
Allow from all
and in the directory "/var/www", the same 2 lines. I don't know why, but the rules RewriteLog n
does not word in the .htaccess. In the "/var/www", I created 2 files, index.html (the default) and test.php. The test.php contains
<?php phpinfo(); ?>
When I call the page index.html, the php info is displayed
One more time, thanks.
精彩评论