This is a discussion on Handle mistyping qqq instead of www? %{} variables? Define $1. Define ^. within the Apache Web Server forums, part of the Web Server and Related Forums category; For instance, if someone mistypes www as qqq or eee in the following, http://www.aquaticcreationsnc.com/ I'm told ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
For instance, if someone mistypes www as qqq or eee in the
following, http://www.aquaticcreationsnc.com/ I'm told I need to get mod_rewrite to do this inside an .htaccess file. The host refuses to allow manual editing of the httpd.conf file (they have some sort of script generator that creates the files). Microsoft on the other hand provides a separate httpd.conf for it's FrontPage. Once those files are edited, FrontPage refuses to connect to the webserver, even if the only edit that occurred was a blank line (i.e., the FrontPage extensions break). And it's a FrontPage thing only so I quit messing with it. FrontPage needs to run for the company owners to access the website (possibly). They understand FrontPage and it works for them. So don't fix what's not broke, right? Anyone here have a link listing all of Apache's %{} variables? The link I found: http://httpd.apache.org/docs/1.3/mod...ml#RewriteCond The following seems to work well enough for what I need it to do. Is this the only way to handle the job? And does it represent the best way to handle the task at hand? RewriteEngine On # handle the absense of a prefix (we want www) RewriteCond %{HTTP_HOST} ^aquaticcreationsnc\.com [nc] RewriteRule ^(.*) http://www.aquaticcreationsnc.com/$1 [R=301,L] # handle mistyped domain names, qqq.aquaticcreationsnc.com and *.aquaticcreationsnc.com RewriteCond %{HTTP_HOST} !^www\.aquaticcreationsnc\.com [nc] RewriteRule ^(.*) http://www.aquaticcreationsnc.com/$1 [R=301,L] And subdomains get placed inside of DNS rather than letting Apache handle them. So I don't have to worry about doing any kind of OR stuff there. Now, to figure out how that ^ caret symbol should be read. I'm reading it as, "match anything ending with..." (almost like a preceding wildcard character), but it has a different meaning in the RewriteRule. Does that somehow get passed down from the Cond line to the Rule line? Any help is greatly appreciated. And anyone able to define $1? Thank you very much for any and all help. Jim Carlock Post replies to the group. -- Swimming Pool Contractors http://www.aquaticcreationsnc.com/ |
|
|||
|
Jim Carlock wrote:
> And does it represent the > best way to handle the task at hand? httpd.conf would be always the beset way. But your first rule is redundant: RewriteEngine On # ...not empty RewriteCond %{HTTP_HOST} !="" RewriteCond %{HTTP_HOST} !^www\.aquaticcreationsnc\.com [nc] RewriteRule ^(.*) http://www.aquaticcreationsnc.com/$1 [R=301,L] > Now, to figure out how that ^ caret symbol should be read. I'm > reading it as, "match anything ending with..." That would be $ (abc$ -> ending with abc). It symbols the starting position of a string. > Does that somehow get passed down from the Cond line to the Rule > line? No, it's a RegEx. But the order of processing is rule-pattern --> condition(s). > And anyone able to define $1? The result captured by evreything between (....), so the part matching the RegEx .* -- Robert |
|
|||
|
"Robert Ionescu" replied:
> your first rule is redundant: RewriteEngine On # ...not empty RewriteCond %{HTTP_HOST} !="" RewriteCond %{HTTP_HOST} !^www\.aquaticcreationsnc\.com [nc] RewriteRule ^(.*) http://www.aquaticcreationsnc.com/$1 [R=301,L] Thanks for catching that. What's the purpose for the first condition above? A blank URI can get passed through an .htaccess file? Jim Carlock Post replies to the group. -- Raleigh Swimming Pool Builder http://www.aquaticcreationsnc.com/ |