Ignore URL variables

Oh, the strange things mod_rewrite does!

Ignore URL variables

Postby sromanski » Tue Oct 27, 2009 7:52 pm

With the following rules. If a url variable is passed then even if a file exists it will be passed on to page.

# Catch 404s.
RewriteCond %{HTTP_HOST} ^www\.site1\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/CT/SYTYCD/%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}/CT/SYTYCD/%{REQUEST_URI} !-d
RewriteRule ^(.*)$ /page.cfm?page=$1 [QSA,L]

Is it possible to have a request to: test.cfm?a=new
not forward to page.cfm if the file test.cfm exists?

If I call the page test.cfm without a URL var it works fine.

Thank you

Simon
sromanski
 
Posts: 9
Joined: Thu Mar 27, 2008 5:39 pm

Postby richardk » Wed Oct 28, 2009 11:27 am

Strange, try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# Catch 404s.
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteCond %{REQUEST_URI} ^(/[^?]+)(\?.*)?$
RewriteCond %{DOCUMENT_ROOT}/CT/SYTYCD%1 !-f
RewriteCond %{DOCUMENT_ROOT}/CT/SYTYCD%1 !-d
RewriteRule ^.+$ /page.cfm?page=$0 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby sromanski » Wed Oct 28, 2009 11:39 am

Thanks you very much.

That works perfectly.
sromanski
 
Posts: 9
Joined: Thu Mar 27, 2008 5:39 pm


Return to Idiosyncrasies

Who is online

Users browsing this forum: No registered users and 2 guests

cron