This is a discussion on mod_rewrite check if file exists within the Apache Web Server forums, part of the Web Server and Related Forums category; I've made some mod_rewrite in order to have pretty urls. RewriteEngine on RewriteRule ^/([a-z]+)$ /$1.html [L] How ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Jacob wrote:
> How can I check that the page $1.html exists before I redirect to it? With a condition RewriteEngine on RewriteCond /var/www/$1.html -f RewriteRule ^/([a-z]+)$ /$1.html [L] Assuming /var/www is your document root. -- Robert |
|
|||
|
Jacob wrote:
> Is something like this possible: > RewriteCond $DocumentRoot/$1.html -f %{DocumentRoot}, yes, but rely on it only, if you know that it contains the correct value. E.g. in cases of using ViatualDocumentRoot, the ENV would be empty. And if you're using the rule only in one virtual host, you can safe a ENV lookup. -- Robert |
| Thread Tools | |
| Display Modes | |
|
|