Forum Moderators: phranque

Message Too Old, No Replies

.htaccess file , why it go to the root/index.html

in the space, it go to the root/index.html

         

heamon

5:05 am on Dec 23, 2006 (gmt 0)



Here is I want:
[aaa.example.net...] ->http://www.example.net/aaa/index.html
[bbb.example.net...] ->http://www.example.net/bbb/index.html

here is what in the .htaccess
RewriteEngine on
rewriterule ^\.htaccess$ - [F]
RewriteCond %{http_host} !^www\.
RewriteCond %{http_host} ^([^.]+)\.example\.net
RewriteCond $1 !^lv_
rewriterule (.*) /lv_%1/$1 [L]

but , when i upload the .htaccess to the root
when i visite [aaa.example.net...] or [lll.example.net...]

it go to one same page ,the page is root indexpage,why?
is the spaces problem?

[edited by: jdMorgan at 5:26 am (utc) on Dec. 23, 2006]
[edit reason] Examplified [/edit]

jdMorgan

5:37 am on Dec 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Good question. This code should work. Have you tried it with proper variable names and directives?

RewriteEngine on
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.net
RewriteCond $1 !^lv_
RewriteRule (.*) /lv_%1/$1 [L]

Do you know that mod_rewrite is working -- Have you tried a simple rewrite like this? :

RewriteRule ^foo\.html$ /bar.html [R=301,L]

If that does not work, mod_rewrite may not be enabled on your server.

By the way, your code should rewrite requests for aaa.example.net/xyz to /lv_aaa/xyz

Here, the "lv_" prefix is used to prevent rewriterule recursion in .htaccess. For another method to achieve the same thing without having to use the directory prefix, see this recent thread [webmasterworld.com].

Also, always flush your browser cache before testing any change to your server configuration code. You must explicitly flush it; reloading the page or restarting the browser won't necessarily work.

Jim

heamon

5:58 am on Dec 23, 2006 (gmt 0)



on the server upload a .htaccess
in the .htaccess:
RewriteEngine on
RewriteRule ^index\.html$ /contact.html [R=301,L]

it work well

but write .htaccess:
RewriteEngine on
Rewritebase /dvd-creator/
RewriteCond %{ENV:rwdone}!^yes$
RewriteCond %{HTTP_HOST}!www\.dvd-creator\.net
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9\-]+)\.dvd-creator\.net
RewriteRule (.*) /%2/$1 [E=rwdone:yes,L]

it can't work!

every url all go to one page ,i don't know why?