Nilesh
Nilesh

Reputation: 1087

How to check for dot(.) in mod_rewrite

I want to redirect URL

domain/Family_He..  

to

domain/Family_Health_insurance 

using RewriteRule. I have tried with

RewriteRule /Family_He(.*)$ /Family_Health_insurance

and it is working. But I have some more page with urls like

domain/Family_Health_info
domain/Family_Health_quote
domain/Family_Health_child etc

When I tried as

RewriteRule /Family_He\.\.$ /Family_Health_insurance

then this won't works for me. Please help me out.

Upvotes: 0

Views: 197

Answers (2)

Gerben
Gerben

Reputation: 16825

To have it redirect (302) you need to add the R flag. To match the dot you need to escape it using \. like

RewriteRule ^/Family_He\.\.$ /Family_Health_insurance [R=302,L]

Note that the leading slash doesn't work in htaccess, only in httpd.conf

Upvotes: 0

Aaron
Aaron

Reputation: 5237

Are you aware that there are actually two spaces at the end of your subject string that would prevent \.$ (a literal dot at the end of the string) from matching?

Upvotes: 1

Related Questions