Ludwig Diehl
asked on
How to centralize .htaccess rules in httpd.conf
Hello everyone!
I was wondering how to set a rewrite rule on the httpd.conf rather than placing a .htaccess on every location
My directory structure:
https://mydomain.com/services/name/rest/index.php
https://mydomain.com/services/name/rest/.htaccess
How to invoke:
https://mydomain.com/services/name/rest/operation/value
My .htaccess content:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?s).*)$ index.php?_action=$1 [QSA,L]
</IfModule>
I was wondering how to set a rewrite rule on the httpd.conf rather than placing a .htaccess on every location
My directory structure:
https://mydomain.com/services/name/rest/index.php
https://mydomain.com/services/name/rest/.htaccess
How to invoke:
https://mydomain.com/services/name/rest/operation/value
My .htaccess content:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?s).*)$ index.php?_action=$1 [QSA,L]
</IfModule>
ASKER
it is not that simple because I only want to apply that rule on a certain condition.
So the condition should be something like this:
https://mydomain.com/services/*/rest/*
Only when /services/*/rest matches
So the condition should be something like this:
https://mydomain.com/services/*/rest/*
Only when /services/*/rest matches
If I understand what you're asking, take a look at how Ubuntu (and all Debian derivatives) handle this.
They provide a directory called /etc/apache2/sites-availab le for virtual hosts.
Then for other common directives, like logging, create a logging.conf file in /etc/apache2 + include it in every virtual host setup file.
They provide a directory called /etc/apache2/sites-availab
Then for other common directives, like logging, create a logging.conf file in /etc/apache2 + include it in every virtual host setup file.
ASKER
Of course I understand what I am asking. I yeah, I like the way debian and Suse handle this. But it is just a matter of creating such a folder and placing there all my vhosts conf files separately. I was just wondering how to achieve what I asked for using wildcards.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you everyone. In the end I had to create separate files.
In general it is not necessary to conditionalize on whether mod_rewrite is available. mod_rewrite is compiled in by default unless Apache was rebuilt specifically without it.