This is a discussion on Simple mod_rewrite Question within the Apache Web Server forums, part of the Web Server and Related Forums category; I have the following rewrite rule: RewriteRule ^/([^/.]+)\.html$ /loadpage.php?filename=$1 How can I make the server rewrite [filename]....
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I have the following rewrite rule:
RewriteRule ^/([^/.]+)\.html$ /loadpage.php?filename=$1 How can I make the server rewrite [filename].html to loadpage.php?filename=[filename] only when [filename].html does not exist on the server? Example: /index.html exists but /page.html does not. http://www.domain.com/index.html will show /index.html, while http://www.domain.com/page.html will be rewritten to /loadpage.php?filename=page because page.html does not exist. Thanks to anyone who will be willing to help me. Trevor |
|
|||
|
trevordixon@gmail.com wrote:
> I have the following rewrite rule: > RewriteRule ^/([^/.]+)\.html$ /loadpage.php?filename=$1 > > How can I make the server rewrite [filename].html to > loadpage.php?filename=[filename] only when [filename].html does not > exist on the server? To check for an non-existing file, use a condition: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^/([^/.]+)\.html$ /loadpage.php?filename=$1 [L] -- Robert |