May
27
htaccess Conditional Loop Redirect
May 27, 2008 |
Like the ‘if’ statement in many programming languages, you can use conditional rule to control mod_rewrite redirect. One very common use for RewriteCond is to prevent looping.
The following rule set causes any request starting with home to be redirected to /home.html. The resulting URL, however, starts with home and will therefore trigger the RewriteRule to be run again. The RewriteCond directive ensures that the rule will be skipped if the request is already for home.html and thus avoids this looping.
RewriteCond %{REQUEST_URI} !^/home\.html
RewriteRule ^home /home.html [R]
Similar Posts
- Remove File Extension Using htaccess
- Use htaccess with Site Maintenance Page
- Block people from Certain URL Using htaccess
- htaccess Permanently redirect file or directory
- htaccess Require the www For Domain URL
- Apache htaccess Prevent Users from Uploading and Executing Files
- htaccess Explicitly Define Default Index File
- Create Custom Error Pages Using htaccess PHP
- htaccess Remove the www From Domain URL
- Google Text Translation Using htaccess
- htaccess Deny Diractory Access During a Specific Time
- Use htaccess for 404 Redirect
- Use htaccess to Fake Different File Extension
- Useful mod_rewrite Resources
- Use htaccess to Deny Access Directory Listing
- htaccess gzip for Faster Loading and Bandwidth Saving
- Block IPs Using htaccess
- Set Local Timezone Using htaccess
- Force Files Like PDF Download using htaccess
- Deny Access to inc Files Using htaccess
- htaccess Limit the Number of Concurrent Visitors to your Website
- Use htaccess to Deny Access to hidden Files
Comments
1 Comment so far



































I can’t describe how helpful this article is! it saved my life! thanks for posting it out!