Forum Moderators: phranque
I'm trying to move a few basic rules from a .htaccess file to .http.conf but even after reading a lot of the previous post on this topic as well as related apache docs I don't seem to be able to make it happen
Those are the rules:
Options All -Indexes
RewriteEngine on
RewriteRule ^pictures/.+-([0-9]+).php pictures.php?view=$1
RewriteRule ^videos/.+-([0-9]+).php videos.php?view=$1
and this is how I put them into httpd.conf:
<Directory /home/*/public_html>
Options +FollowSymLinks +IncludesNoExec -Indexes
RewriteEngine on
RewriteRule ^/pictures/.+-([0-9]+).php pictures.php?view=$1
RewriteRule ^/videos/.+-([0-9]+).php videos.php?view=$1
</Directory>
The rewrite rule don't seem to be working this way
What am I doing wrong?
Also I would like to use AllowOverride None, where to put it?
thank you,
Catalin
<Directory /home/*/public_html>
Options +FollowSymLinks +IncludesNoExec -Indexes
RewriteEngine on
RewriteRule ^/pictures/[^-]+-([0-9]+)\.php [b]/p[/b]ictures.php?view=$1 [L]
RewriteRule ^/videos/[^-]+-([0-9]+)\.php [b]/v[/b]ideos.php?view=$1 [L]
</Directory>
AllowOverride None can go anywhere within the directory container. Order of execution is per-module, as determined by the server loadmodule list, not per-line. That is, directives for a particular Apache module execute in order, but the order that those modules execute and parse those directives is set by the server.
Jim
/pictures/description-of-picture-1642.php -> /picture.php?view=1642
Then, it does not work "rooting" the pictures.php file and as I tested it, does not work for the simplest constructions, it's like the rules does not exist in the httpd.conf when they work just fine in the .htaccess file
after each change I run >service httpd restart so everything should work fine
do you have any idea?
RewriteRule ^/pictures/([^-]+-)*([0-9]+)\.php$ /pictures.php?view=$2 [L]
RewriteRule ^/videos/([^-]+-)*([0-9]+)\.php$ /videos.php?view=$2 [L]
Also note the end-anchor on the patterns, which will also improve efficiency.
None of that matters if the rules don't run at all, though...
Are you sure you don't already have an "AllowOverride None" in force? You will need to allow FileInfo at least in order for mod_rewrite to work. Certainly, it would be a good idea to AllowOverride All and then test the mod_rewrite code to see if there's some interference.
Is there anything useful in your server error log? If not, try 'breaking' the mod_rewrite code and checking it again. To break the code, just add an extra space in either the pattern or the substitution, and you should get an "invalid flags delimiter" error from mod_rewrite -- IF it's being invoked at all.
One other thing to check is that the directory template for your <directory> container should match the DcoumentRoot declaration for the <directory> in question.
Also, what version of Apache are you running?
And, as always, flush your browser cache after any code change/server restart.
Jim
As for moving them to httpd.conf I still had no luck
Here is my apache confing from httpd.conf:
DocumentRoot /usr/local/apache/htdocs
<Directory />
Options All
AllowOverride All
</Directory>
<Directory "/usr/local/apache/htdocs">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<IfModule mod_userdir.c>
UserDir public_html
</IfModule>
<Directory /home/*/public_html>
Options -Indexes
</Directory>
Options -Indexes directive works fine but if I use in the same directory ( /home/*/public_html ) the rewrite rules they have absolutely no effect
Then I tried changing Documentroot which doesn't seem to be /usr/local/apache/htdocs , to /home/earth and this changed the situation a bit, putting the rewrite rules to <Directory "/home/earth/public_html"> partially works, but the problem is I get an error ( on the error_log ) related to MultiViews and I'm also not sure changing Documentroot would be the way to go ( this being the default setting )
If you could give me a bit more help on how to make this right I'll be more than happy, because no matter how many times I read what each of the config file components do on apache's docs I still can't put them together without an example ( some advice )
thank you,
Catalin
Hopefully, someone else will spot the problem, but I don't see it.
Jim