How can I store {REQUEST_URI} in a variable, manipulate it and then use it in a RewriteCond or RewriteRule
How can I store {REQUEST_URI} in a variable, manipulate it and then use it in a RewriteCond or RewriteRule?
Basically, here is what I am looking to do.
1.) Get the {REQUEST_URI} and change .shtml to .html, store this in a variable called URL_MOD
2.) Test for the existence of a file with that name of the newly created Variable called URL_MOD
3.) Based on the test result, redirect users to a domain with the URL_MOD appended.
RewriteCond %{REQUEST_FILENAME} (.*)\.html
RewriteCond %{REQUEST_URI} (.*)\.html
RewriteCond %1.shtml -f
RewriteRule (.*) http://new.example.com%2.shtml
Check more discussion of this question.
Related posts:
- Apache RewriteRule with a RewriteMap variable substitution for the VAL argument to environment variable
- mod_rewrite: Use backreference from RewriteCond as CondPattern in another RewriteRule
- How do I fix my usage of RewriteCond in our MediaWiki .htaccess file?
- Apache RewriteRule ignoring RewriteCond?
- RewriteRule applying pattern even though 1 of the RewriteCond’s failed
Leave a comment
Recent Posts
- Is there a way for administrators to disable users from installing Firefox extensions?
- Is there research material on NTP accuracy available?
- How to create a limited “domain admin” that does not have access to domain controllers?
- Can Windows RDC admin users be immune from being kicked?
- Domain Administrators account policy (After PCI audit)
Tags
active-directory
amazon-ec2
apache
apache2
backup
bash
centos
cisco
command-line
debian
dns
email
exchange
firewall
iis
iis7
iptables
linux
macosx
monitoring
mysql
networking
nginx
performance
permissions
php
postfix
raid
security
sql-server
sql-server-2005
sql-server-2008
ssh
ssl
ubuntu
unix
virtualization
vpn
webserver
windows
windows-7
windows-server-2003
windows-server-2008
windows-server-2008-r2
windows-xp





