Forum Moderators: phranque
Using a software which requieres a rewrite condition, but the application is copied between differnt servers and you never now directly "does the linux server support rewriting?". When rewriting is possible it should use it, otherwise it will use a fallback condition.
I tried a lot, but could not find any solution for the problem, that's why i'm ot going to put any tries here.
Here is what is requiered, but i have no idea how to manage this:
<test for mod_rewrite is possible>
<if requested directory does not contains files or images or,....>
<if request does not contain ^(.*).php?page(.*)$>
Redirect all requests to /index.php?key={everything after "domain.tld/" in the request}
<if request does not contain ^(.*).php?page(.*)$>
</if requested directory does not contains files or images or,....>
</test for mod_rewrite is possible>
Maybe you could parse the httpd.conf file?
If there is a line somewhat like the one below in it I guess it is safe to say the server supports rewriting.
LoadModule rewrite_module /the/path/to/apache/mod_rewrite.so
Alternatively maybe you could check for the presence of the 'mod_rewrite.so' file on the system?
There may be better methods, the above is just what came to my mind first.
I ment that I will not have access to the httpd.conf.
The reason why I need an .htaccess file with this configuration is, that I don't want to check for beeing able to use rewriting. I just want to use rewriting if I am allowed to use it on the single server.
When I go and install a piece of software on target server X, there should be no reason to contact the system administrator and ask him for rewriting is allowed for the webspace the software is uploaded to. The software will automaticaly configure itself, when the website is hit by a client browser for the first time.
The purpose is:
Use rewriting if possible, otherwise don't.
So the question is, is it possible to query inside a .htaccess file, whether this webspace is allowed to use rewriting and if yes how this code would look like?
Thanks :-)
<IfModule mod_rewrite.c>
# do something
</IfModule>
[httpd.apache.org...]
The <IfModule test>...</IfModule> section is used to mark directives that are conditional. The directives within an IfModule section are only processed if the test is true. If test is false, everything between the start and end markers is ignored.
>I need to check whether i am allowed to use rewriting at all.
I have a hard time thinking of another reason why mod_rewrite would be installed. I guess that if .htaccess overrides are not allowed in the folder where you work it wouldn't work there, but then it wouldn't make sense to have an .htaccess file there in the first place afaik.