Forum Moderators: phranque

Message Too Old, No Replies

htaccess issue

problems with subdomain

         

rebz

7:13 pm on Jun 22, 2010 (gmt 0)

10+ Year Member



ok so i actually have the subdomain workin (sort of)

one of the links is this
[bf2s.tehclan.net...] => [tehclan.net...]
the link works but in the address bare it shows the original link instead of my subdomain for example

[tehclan.net...]
should be [bf2s.tehclan.net...]

this is my htaccess
# In httpd.conf set the following option
# AllowOverride All

<IfModule mod_rewrite.c>
RewriteEngine on


RewriteBase /


#Options +FollowSymlinks
RewriteCond %{HTTP_HOST} ^stats\.tehclan\.net$ [NC]
RewriteRule ^(.*)$ http://tehclan.net/bf2statistics/$1 [L,R]

RewriteCond %{HTTP_HOST} ^bf2s\.tehclan\.net$ [NC]
RewriteRule ^(.*)$ http://tehclan.net/bf2sclone/$1 [L,R]

RewriteCond %{HTTP_HOST} ^forum\.tehclan\.net$ [NC]
RewriteRule ^(.*)$ http://tehclan.net/forum/$1 [L,R]

RewriteCond %{HTTP_HOST} ^rebz01\.tehclan\.net$ [NC]
RewriteRule ^(.*)$ http://tehclan.net/rebz01/$1 [L,R]

</IfModule>


its only a matter of preference like i said the links work they just dont display correctly in the address bar, is there something missing?

i am using xampp if that helps

g1smd

8:05 pm on Jun 22, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You have redirected the user with a 302 redirect.

The redirect instructs the browser to make a new request for a new URL.

The browser will always show that new URL in the address bar.

You may be looking for a rewrite rather than a redirect.

rebz

8:13 pm on Jun 22, 2010 (gmt 0)

10+ Year Member



so can you point me in the right direction?
ty for your reply

jdMorgan

8:31 pm on Jun 22, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You want a URL-to-filepath translation, not a URL-to-URL redirect:

# AllowOverride All
#
#Options +FollowSymlinks
#
RewriteEngine on
RewriteBase /
#
RewriteCond %{HTTP_HOST} ^stats\.tehclan\.net [NC]
RewriteRule ^(.*)$ /bf2statistics/$1 [L]
#
RewriteCond %{HTTP_HOST} ^bf2s\.tehclan\.net [NC]
RewriteRule ^(.*)$ /bf2sclone/$1 [L]
#
RewriteCond %{HTTP_HOST} ^(forum|rebz01)\.tehclan\.net [NC]
RewriteRule ^(.*)$ /%1/$1 [L]

Re-ordered module directives based on dependencies.
<IfModule> not needed unless you want this code to fail silently if mod_rewrite is not loaded.
Do not end-anchor hostnames unless you want FQDN hostnames and hostnames with appended port numbers to fail, e.g. example.com:80, example.com. or example.com.:80 -- all valid hostnames, but non-canonical.

[added]
Be aware that this code will 'allow' StAtS.tehclan.net to be rewritten, and since Apache is case-sensitive, these requests will likely not resolve to an existing subdirectory.

I suggest removing the [NC] flags, and -optionally- detecting and redirecting mis-cased or mixed-case hostname requests to the properly-cased hostname. However, since all legitimate HTTP clients will only request all-lowercase hostnames, the latter step is not strictly necessary, since most mis-cased request will be from bad-bots.
[/added]

Jim

rebz

9:02 pm on Jun 22, 2010 (gmt 0)

10+ Year Member



i changed my htaccess to the following as you said


# AllowOverride All
#
#Options +FollowSymlinks
#
RewriteEngine on
RewriteBase /
#
RewriteCond %{HTTP_HOST} ^stats\.tehclan\.net [NC]
RewriteRule ^(.*)$ /bf2statistics/$1 [L]
#
RewriteCond %{HTTP_HOST} ^bf2s\.tehclan\.net [NC]
RewriteRule ^(.*)$ /bf2sclone/$1 [L]
#
RewriteCond %{HTTP_HOST} ^(forum|rebz01)\.tehclan\.net [NC]
RewriteRule ^(.*)$ /%1/$1 [L]

but now i get a 500 error

[edit]
do i need to change anything in the conf file?
or have i simply misunderstood your instructions?

jdMorgan

10:09 pm on Jun 22, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry -- Because of the "AllowOverride All" directive (which is allowed only in config files), I thought this code *was* in your config file...

If it's in example.com/.htaccess, you need to explicitly prevent recursion:

#Options +FollowSymlinks
#
RewriteEngine on
RewriteBase /
#
RewriteCond $1 !^bf2statistics/
RewriteCond %{HTTP_HOST} ^stats\.tehclan\.net [NC]
RewriteRule ^(.*)$ /bf2statistics/$1 [L]
#
RewriteCond $1 !^bf2sclone/
RewriteCond %{HTTP_HOST} ^bf2s\.tehclan\.net [NC]
RewriteRule ^(.*)$ /bf2sclone/$1 [L]
#
RewriteCond $1 !^(forum|rebz01)/
RewriteCond %{HTTP_HOST} ^(forum|rebz01)\.tehclan\.net [NC]
RewriteRule ^(.*)$ /%1/$1 [L]

When you get a 500-Server Error, check your server error log -- It will often tell you exactly what the problem is.

Jim

rebz

11:12 pm on Jun 22, 2010 (gmt 0)

10+ Year Member



excellent fixed works great!

much appreciated