Forum Moderators: phranque

Message Too Old, No Replies

Close a folder

         

khuram

5:20 pm on Jan 4, 2010 (gmt 0)

10+ Year Member



Hi,

Is it possible to close a folder through htaccess.
All i want to do is to make all requests from /forum/* to fall back to root folder index.php file.

Is this,
#RewriteRule ^/forum(.*)$ / [L,R=301]

good enough.

please advice,

Kind regards,

g1smd

1:09 am on Jan 5, 2010 (gmt 0)

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



Make sure the target URL specifies the protocol and domain as well as the / path.

You don't need the (.*) part as you have no need to capture and re-use that part of the URL.

You don't need the / immediately after the ^ if the code is for use in .htaccess.

khuram

10:16 am on Jan 5, 2010 (gmt 0)

10+ Year Member



Hi G1smd

can you plesae write the full rule to add in my htaccess here.

Kind regards

g1smd

10:54 am on Jan 5, 2010 (gmt 0)

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



You write it, and I'll tell you where you're going wrong.

khuram

11:12 am on Jan 5, 2010 (gmt 0)

10+ Year Member



Hi G1smd,.

hows this

RewriteRule ^forum http://www.example.com/ [L,R=301]

because its not working. :(

g1smd

11:25 am on Jan 5, 2010 (gmt 0)

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



In what way does it "not work"?

Include results from "Live HTTP Headers".

Did you clear/flush the browser cache before testing?

khuram

11:42 am on Jan 5, 2010 (gmt 0)

10+ Year Member



Hi g1smd,

I cleared browser cache. What I want is, if I type http://www.example.com/forum/
then I should be sent back to http://www.example.com/. But right now, with this rule, http://www.example.com/forum is opening.

g1smd

1:57 pm on Jan 5, 2010 (gmt 0)

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



Do you have any "rewrites" (as opposed to "redirects") in your .htaccess file?

If so, this redirect must go before all of the rewrites, otherwise they will grab the request first.

khuram

2:51 pm on Jan 5, 2010 (gmt 0)

10+ Year Member



there are only a few rules before this redirect
And those are to force www and https on selected pages.

jdMorgan

5:14 pm on Jan 5, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Re-iterating what g1smd posted, order your rules with external redirect {[R=30x,L]} rules first, in order from most-specific patterns and conditions to least-specific, followed by all internal rewrites, again in order from most-specific to least-specific.

Completely flush your browser cache (delete it) before testing any new server-side code.

Make sure that this code is located in a .htaccess file in a directory that will be traversed during the directory-walk for the client-requested URL.

If none of this helps, make the changes suggested above and then re-post, showing any rules which precede this new rule, and one or two that follow it (please change all domain name references to "example.com").

Sometimes the problem is rule order, and sometimes the problem is mistaken assumptions because important information has not been posted, and becomes obvious only from looking at the other rules. It may in fact require a complete "code-dump" to find the problem, but that practice is discouraged here unless absolutely necessary.

Jim