Welcome to WebmasterWorld Guest from 3.80.6.254

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

Query in .htaccess: Is mod_rewrite possible in current dir

Check for mod_rewrite before trying to apply conditions

     
1:55 pm on Jan 16, 2004 (gmt 0)

New User

10+ Year Member

joined:Jan 16, 2004
posts:6
votes: 0


The Problem:

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>
12:59 pm on Jan 19, 2004 (gmt 0)

Preferred Member

10+ Year Member

joined:Dec 19, 2000
posts:366
votes: 0


Welcome to Webmasterworld cyberskater.

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.

2:30 pm on Jan 19, 2004 (gmt 0)

New User

10+ Year Member

joined:Jan 16, 2004
posts:6
votes: 0


Sorry, maybe you did not get the point :-)

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 :-)

2:58 pm on Jan 19, 2004 (gmt 0)

Preferred Member

10+ Year Member

joined:Dec 19, 2000
posts:366
votes: 0


Maybe this helps:
I think in both httpd.conf and .htaccess you could write something like

<IfModule mod_rewrite.c>
# do something
</IfModule>

[httpd.apache.org...]

3:28 pm on Jan 19, 2004 (gmt 0)

New User

10+ Year Member

joined:Jan 16, 2004
posts:6
votes: 0


But I always thought, this only checks whether this module is installed? I need to check whether i am allowed to use rewriting at all.

Or does this query result in just that?

4:29 pm on Jan 19, 2004 (gmt 0)

Preferred Member

10+ Year Member

joined:Dec 19, 2000
posts:366
votes: 0


>But I always thought, this only checks whether this module is installed?
Did you follow the link and read the documentation as well?
If I understand your problem properly now it describes what you need.


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.

5:00 pm on Jan 19, 2004 (gmt 0)

New User

10+ Year Member

joined:Jan 16, 2004
posts:6
votes: 0


Well ok, I'll play arround a little more.
I'll post the final result, when I am through to show you what i mean :-)