mrperfect75000
asked on
Exempting specific files from Rewrite Engine.
I have this code right now that works...
when i type something like www.mysite.com/first_test.html
it gives me www.mysite.com/result.asp?kwds=first test, but it still keeps the static html(for SEO purposes)
RewriteEngine on
RewriteRule ^([0-9a-zA-Z]+)[_]([0-9a-z A-Z]+)[_]( [0-9a-zA-Z ]+).*$ results.asp?kwds=$1+$2+$3
RewriteEngine on
RewriteRule ^([0-9a-zA-Z]+)[_]([0-9a-z A-Z]+).*$ results.asp?kwds=$1+$2
The problem is, if for example i have a real file that is named second_test.html on my server with content in it.
When i type in www.mysite.com/second_test.html ....it rightfully takes me to
www.mysite.com/result.asp?kwds=second test
Is there a way for me to exempt certain files from being excuted by this script?
So that when i type in www.mysite.com/second_test.html i get the actual file on the server not the generated page. I only want to be able to specify certain files not to be excuted by this script.
Please help.
Thanks.
when i type something like www.mysite.com/first_test.html
it gives me www.mysite.com/result.asp?kwds=first test, but it still keeps the static html(for SEO purposes)
RewriteEngine on
RewriteRule ^([0-9a-zA-Z]+)[_]([0-9a-z
RewriteEngine on
RewriteRule ^([0-9a-zA-Z]+)[_]([0-9a-z
The problem is, if for example i have a real file that is named second_test.html on my server with content in it.
When i type in www.mysite.com/second_test.html ....it rightfully takes me to
www.mysite.com/result.asp?kwds=second test
Is there a way for me to exempt certain files from being excuted by this script?
So that when i type in www.mysite.com/second_test.html i get the actual file on the server not the generated page. I only want to be able to specify certain files not to be excuted by this script.
Please help.
Thanks.
If you want a generic rule that only rewrites if a given file does NOT exist (and it sounds like you might want that),
RewriteCond %{REQUEST_FILENAME} !-f
would test for that (inside the server configuration; insite a .htaccess it's %{DOCUMENT_ROOT}/%{REQUEST _FILENAME} instead).
You also do not need more than one RewriteEngine on. So in the end, your ruleset would look like this :
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([0-9a-zA-Z]+)[_]([0-9a-z A-Z]+)[_]( [0-9a-zA-Z ]+).*$ results.asp?kwds=$1+$2+$3
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([0-9a-zA-Z]+)[_]([0-9a-z A-Z]+).*$ results.asp?kwds=$1+$2
RewriteCond %{REQUEST_FILENAME} !-f
would test for that (inside the server configuration; insite a .htaccess it's %{DOCUMENT_ROOT}/%{REQUEST
You also do not need more than one RewriteEngine on. So in the end, your ruleset would look like this :
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([0-9a-zA-Z]+)[_]([0-9a-z
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([0-9a-zA-Z]+)[_]([0-9a-z
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks! If i had more than one file i want to exlude - do i have to do include each one?
Thanks for your help...
Thanks for your help...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
RewriteCond %REQUEST_URI !^/path/(doc-name1|doc-nam
The next RewriteRule that follows this can only execute if the REQUEST_URI is none of the following:
/path/doc-name1.html
/path/doc-name2.html
/path/doc-name3.html
You ought to be able to use this pattern to rule out a number of actual static HTML files that you don't want redirected to a script.
However, my site is small, and I'm not sure if this multi-name pattern can scale up to a large number of document names.
See the RewriteCond section in the Apache docs:
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteCond