Forum Moderators: phranque

Message Too Old, No Replies

whats wrong in my htaccess

virtualhost mode rewrite

         

Kermit

5:48 pm on Oct 10, 2007 (gmt 0)

10+ Year Member



Hi,
I got some problem in my htaccess

RewriteEngine on
RewriteCond %{HTTP_HOST} example.cz$ [NC]
RewriteCond %{REQUEST_URI} !^/---example/.*$
RewriteRule ^(.*)$ /---example/$1

when I want to open a folder http://www.example.cz/test-folder
it opens me this one http://www.example.cz/---example/test-folder

whats wrong?

[edited by: jdMorgan at 10:39 pm (utc) on Oct. 10, 2007]
[edit reason] example domain [/edit]

jdMorgan

10:41 pm on Oct 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Apparently, nothing is wrong. The code is designed to act exactly in the way you describe; It prepends "/---example" to any URL which does not already start with "/---example".

So we need to know what you intended to do instead.

Jim

Kermit

7:26 am on Oct 11, 2007 (gmt 0)

10+ Year Member



Thanks for reply (and my apology for not using example)

I have two domains on one hosting so I would like to put the second one in a specific folder (dir) and when someone type this domain name to
get in to that folder but not to make a change in url.

So when you want to open http://www.example.com/ it opens precisely http://www.example.com/ (and to not add "dir" nothing after) and when I want to open http://www.example.com/test-folder/ to open as it is and to not add "dir" as I show you In my previous post.

Thank you

jdMorgan

11:29 am on Oct 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, but still not clear, because "http://www.example.com/test-folder/" is not a domain, it's a folder.

I think you're looking for a 'system' here, because one rule is not really enough.


RewriteEngine on
#
# Internally rewrite requests for second-domain.com to "/-second-domain" subdirectory
RewriteCond %{HTTP_HOST} second-domain\.com [NC]
RewriteCond %{REQUEST_URI} !^/-second-domain/
RewriteRule (.*) /-second-domain/$1 [L]
#
# Externally redirect client requests for /-second-domain/<page> back to second-domain.com/<page>
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /-second-domain/
RewriteRule ^-second-domain/(.*)$ http://second-domain.com/$1 [R=301,L]

If you wish to exclude certain test directories or perhaps things like common image or script directories from being rewritten, just add one or more negative-match RewriteConds to the first rule:

RewriteCond %{REQUEST_URI} !^/test-dir/
RewriteCond %{REQUEST_URI} !^/common-images/
RewriteCond %{REQUEST_URI} !^/common-scripts/
...

Jim