mod_rewrite problem with tilde

Fabian Keil freebsd-listen at fabiankeil.de
Fri Jul 13 19:18:19 UTC 2012


David Banning <david+dated+1342623098.665e12 at skytracker.ca> wrote:

> I am migrating to a new server location which right now
> has no domain name, so the ip address is being used.
> The ISP gives an address for the apache directory like so;
> 
> http://184.154.230.2/~smartst2/
> 
> A simple redirect works, such as this one which directs to another
> site;
> 
> Options +FollowSymLinks
> rewriteEngine on
> rewriteRule ^test\.html$ http://www.somesite.com/index.php [R=301,L]
>
> but a redirect within the site does not work.  I wonder if it has to 
> do with the tilde ~ character that the ISP has configured.
> 
> I presently have the following .htaccess;
> 
> RewriteEngine on
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteCond %{REQUEST_FILENAME} !-l
> RewriteRule   ^[^/]*\.php$  /
> RewriteRule   ^[^/]*\.html$  index.php
> 
> Which does not work. If anyone is aware of problems using 
> mod_rewrite with the ~ character or could contribute any pointers
> as to how I could gain more information on - for instance -where-
> mod_rewrite is -attempting- to redirect (considering my above 
> .htaccess. 

If you access your server with "curl -v" it will show you
were the response redirects to (if you get a redirect at
all). Checking the Apache logs would be another option,
but it may require fiddling with the log levels first.

Without knowing the URL you use for testing it's hard to
tell where the problem is, but my guess is that you are
matching against a text that contains one or more slashes
which your patterns don't allow.

Fabian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20120713/988bf332/signature.pgp


More information about the freebsd-questions mailing list