Really really basic htaccess question

software development

#1

I’m just starting out with .htaccess and ive been struck what is probably a really basic problem. :slight_smile:

I have the .htaccess file in the site directory (the same level as that site’s index file) and just to make sure i could do the right thing I wrote this thing I wrote

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)w/$ $1v/ [R]

thinking it will take “http://www.example.com/w/” and go to “http://www.example.com/v/” It actually goes to “http://www.example.com/home/~user/www.example.com/v/

which is not what I expected at all.

is there something wrong with the basic ideas of my regex? do i need more in my .htaccess file? is its placement wrong?

Thanks in advance for your assistance.


#2

Try

Options FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^(.*)w/$ $1v/ [R]The RewriteBase tells mod_rewrite the base url-path prefix to reinsert. Also, there is no leading / in the URL when you get to RewriteRule:

URL = w/

$1 = (null)

Substitution = v/

oops, v/ is not a URL. So it had to make it a URL, but we don’t have a base so we use the document root instead, /home/username/domain/

:cool: openvein.org -//- One-time [color=#6600CC]$50.00 discount[/color] on [color=#0000CC]DreamHost[/color] plans: Use ATROPOS7