Forum Moderators: phranque

Message Too Old, No Replies

preventing direct access toa part of a website

redirecting to linker

         

Plebb

7:59 am on Dec 29, 2010 (gmt 0)

10+ Year Member



Hello I have a similar problem that is eluding me,

I am trying to prevent direct access to a part of my website and only allow access via a link from another place on the website

its like this I want to prevent access to
http://mysite.com/gallery/
and be redirected to
http://mysite/forum/
then from the forum a linked button will take the user to the http://mysite.com/gallery/.

I have in my .htaccess the following but it does absolutely nothing, after many attempts and sometimes getting a 500 error im now pleading for some help

RewriteEngine on
RewriteCond %{HTTP_HOST} !http://mysite.com/gallery/$ [NC]
RewriteRule (.*){HTTP_HOST}http://mysite.com/forum/ [L,R]

Plebb

8:03 am on Dec 29, 2010 (gmt 0)

10+ Year Member



my laptop is itchy and I couldnt edit this post so here is an addendum

can anyone please help or point me in the right direction.

P.

Many thanks in advance.

g1smd

9:06 am on Dec 29, 2010 (gmt 0)

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



If you simply set a redirect from /gallery to /forum this will affect all users every time. No-one would ever be able to view any of the gallery.

If you base this code on the referring URL, visitors would only be able to look at one page of the gallery and then the referrer would be wrong and they would be redirected back to the forum.

HTTP_HOST holds only the domain name. It does not hold any path data. Other variables such as SERVER_PORT, REQUEST_URI, QUERY_STRING and THE_REQUEST hold other parts of the whatever the browser requested.

However, in this case it would be the wrong approach to try to use REFERER data.

You will need to set cookies in the forum and then check for them in the gallery.

Plebb

5:57 pm on Dec 29, 2010 (gmt 0)

10+ Year Member



ok thanks I will give it a go,