regular expression and mod_rewrite

Using mod_rewrite to handle various content issues

regular expression and mod_rewrite

Postby p.bacarella » Tue Feb 20, 2007 2:55 pm

Hi,
I've a little problem with mod_rewrite and regular expressions.
Supposed I have the website http://www.mysite.com

When I type on the browser "http://www.mysite.com" I need to open the file in path /path/to/homepage.htm but when I type on the browser "http://www.mysite.com/?variable=value" or "http://www.mysite.com/index.php?variable=value" I need to open the real page /apache/documentroot/index.php indicated by the directive DocumentRoot of apache configuration file (I mean I don't need rewrite rules).

How can I write the mod_rewrite rules in order to resolve my problem?
Thanks a lot,

Piero
p.bacarella
 
Posts: 2
Joined: Tue Feb 20, 2007 2:54 pm

Postby richardk » Tue Feb 20, 2007 2:59 pm

Make sure the query string is empty
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(index\.php)?$ /path/to/homepage.htm [L]


Remove (index\.php)? if you don't want /index.php to be sent to /path/to/homepage.htm.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby p.bacarella » Tue Feb 20, 2007 3:09 pm

richardk wrote:Make sure the query string is empty
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(index\.php)?$ /path/to/homepage.htm [L]


Remove (index\.php)? if you don't want /index.php to be sent to /path/to/homepage.htm.




GREAT! It works.
Thanks a lot,

Piero :D
p.bacarella
 
Posts: 2
Joined: Tue Feb 20, 2007 2:54 pm


Return to Content

Who is online

Users browsing this forum: No registered users and 11 guests

cron