Reputation: 504
I'm totally new to IHS and I faced the problem that I need to redirect the URL of my homepage, www.example.com/foo --> www.example.com/foo/bar
another thing that some of the paths like www.example.com/foo/somethingelse
are correct, I have read numerous of articles realated to mod_rewrite talking about alot more complex solutions but failed to find such simple solution like this. Also, I get really confused about that regex thing yet.
Please help, thanks.
Upvotes: 0
Views: 194
Reputation: 66
For your example you want requests that have the HTTP Host header set to www.example.com and have a URI that is just /foo or /foo/ to be redirected to www.example.com/foo/bar The following example is a rewrite rule to achieve this
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^/foo/?$ /foo/bar [R,L]
You can find in-depth documentation on Rewrites at the following sites:
http://publib.boulder.ibm.com/httpserv/manual70/rewrite/rewrite_guide.html
http://publib.boulder.ibm.com/httpserv/manual70/rewrite/rewrite_guide_advanced.html
Upvotes: 5
Reputation: 829
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.\.com [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{foo}
</IfModule>
Upvotes: 1