You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jason Williard <jw...@pcsafe.com> on 2006/02/03 09:27:02 UTC
[users@httpd] Rewrite/RedirectMatch Issues
I have been having trouble getting some Rewrites or Redirects to work. Here
is what I am trying to do:
http://weather.domain.com/ -> http://www.domain.com/weather/
http://weather.domain.com/##### -> http://www.domain.com/weather/#####
http://weather.domain.com/@@@@@ -> http://www.domain.com/weather/@@@@@
The ##### represents a string of 5 digits (US zip code). The @@@@@ string
represents any text (aimed at the name of a city).
Here is what I currently have. I've gone through many changes, but this
seems to be the closest to working properly:
Redirect /index.php http://www.domain.com/weather/
RedirectMatch ^/([0-9]{5}) http://www.domain.com/weather/$1
RedirectMatch ^/([A-Za-z]+) http://www.domain.com/weather/$1
The problem with this is the last line is interpreting "index.php" as
"/index" and appending that to the end. The second line works perfectly.
How can I get the last line to work without seeing index.php, or index, as a
match?
Also, when it gets to http://www.domain.com/weather/$1, I am experiencing a
similar issue. The images/ folder is in a folder called weather/. So, with
the rules that I have in place, the images are not showing up. I'd like to
know if there is a way to follow the rules while excluding the weather
folder.
Here are the rules for that:
RewriteRule ^weather/$
cgi-bin/weather/hw3.cgi?forecast=asus01&use_map=us_c_sm_albers2 [NC]
RewriteRule ^weather/([0-9]{5}) cgi-bin/weather/hw3.cgi?pands=$1
[NC]
RewriteRule ^weather/([A-Za-z]+) cgi-bin/weather/hw3.cgi?pands=$1
[NC]
----
Thank You,
Jason Williard
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Rewrite/RedirectMatch Issues
Posted by Joshua Slive <jo...@slive.ca>.
On 2/3/06, Jason Williard <jw...@pcsafe.com> wrote:
> Redirect /index.php http://www.domain.com/weather/
> RedirectMatch ^/([0-9]{5}) http://www.domain.com/weather/$1
> RedirectMatch ^/([A-Za-z]+) http://www.domain.com/weather/$1
>
>
> The problem with this is the last line is interpreting "index.php" as
> "/index" and appending that to the end. The second line works perfectly.
> How can I get the last line to work without seeing index.php, or index, as a
> match?
I think you need to tag $ on the end of your regexes to indicate the
end-of-string. Otherwise any trailing characters will match.
>
>
> Also, when it gets to http://www.domain.com/weather/$1, I am experiencing a
> similar issue. The images/ folder is in a folder called weather/. So, with
> the rules that I have in place, the images are not showing up. I'd like to
> know if there is a way to follow the rules while excluding the weather
> folder.
Do you mean you want to exclude the "images" folder? If so, you can
add something like
RewriteRule ^weather/images - [L]
at the top. Otherwise, I can't understand what you are asking.
Joshua.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org