Simple mod_rewrite Question

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]....


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2006
trevordixon@gmail.com
 
Posts: n/a
Default Simple mod_rewrite Question

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

  #2 (permalink)  
Old 01-06-2006
Robert Ionescu
 
Posts: n/a
Default Re: Simple mod_rewrite Question

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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:44 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0