Hello together,
I would like to use Apaches mod_rewrite to redirect from http://webpage.com to http://www.webpage.com
The URL path may ofcourse hold a path of folders and some further parameters like so: http://webpage.com/folder1/folder2/mysr ... tion=start
RewriteCond %{HTTP_HOST} ^\.webpage\.com seems to be a good start. But how do I actually form the RewriteRule? I need to get hold of REQUEST_URI and QUERY_STRING (which can be empty or not). Howto?
Thanks,
visionmaster
RegExp and Apache RewriteEngine (missing www.)
Moderator: General Moderators
-
visionmaster
- Forum Contributor
- Posts: 139
- Joined: Wed Jul 14, 2004 4:06 am
What about something like:
This is untested of course ubt does the idea make sense?
Code: Select all
RewriteRule /^webpage.com(.*)$/ www.webpage.com$1Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
it does allow you to do it, indirectly..not tested, but from memory.. may be a tiny bit off.
Code: Select all
RewriteEngine on
RewriteCond %{HTTP_HOST} ^webpage.com$
RewriteRule /(.*) http://www.webpage.com/$1-
visionmaster
- Forum Contributor
- Posts: 139
- Joined: Wed Jul 14, 2004 4:06 am
@feyd thanks for your help, I was thinking much to complicated. It works like this:feyd wrote:it does allow you to do it, indirectly..not tested, but from memory.. may be a tiny bit off.Code: Select all
RewriteEngine on RewriteCond %{HTTP_HOST} ^webpage.com$ RewriteRule /(.*) http://www.webpage.com/$1
Code: Select all
RewriteEngine on
RewriteCond %{HTTP_HOST} ^webpage.de$
RewriteRule (.*) http://www.webpage.de/$1Thanks to you all!