2

I am trying to do the following rewrite of tilde URLs:

RewriteRule ^/?~folder/(.*) http://whatever.com/$1 [R=302,L]

I want any links with whatever.com/~folder/something to become whatever.com/something.

It seems that the above rewrite rule works if my situation excluded the tilde (also tried escaping it, \~ ), but with the tilde it does not perform the rewrite.

Is there a broader configuration setting I need to adjust to enable rewriting in my situation? I understand normally ~folder refers to a user's home directory, but I don't know how that comes into play or can be adjusted in my situation.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
apa456
  • 21
  • 1
  • 3

3 Answers3

2

I was able to fix any hits to http://domain.ext/~blog/file.html with this .htaccess rule at webroot (public_html):

RewriteRule ^~blog/(.*)$ /site/legacy/users/blog/$1 [R=301,L]

From: http://webmaster.iu.edu/tools-and-guides/maintenance/redirect-htaccess.phtml

Sigg3.net
  • 43
  • 4
0

I use this rule to redirect everything which starts with tilde

RewriteCond %{REQUEST_URI} ^/~([a-z]+)/
RewriteRule ^(.*)$ http://www.mysite.fr/$1 [R=301,L]

From @Sigg3.net source : http://webmaster.iu.edu/tools-and-guides/maintenance/redirect-htaccess.phtml

Mario Radomanana
  • 1,698
  • 1
  • 21
  • 31
0

It is probably linked to the use mod_userdiras you mention. Please check in your apache configuration if it is now activated and see if disabling it fixes the issue.

http://httpd.apache.org/docs/2.2/mod/mod_userdir.html

Oct
  • 1,505
  • 13
  • 18