htaccess q?
- Started
- Last post
- 13 Responses
- mikotondria3
not being an expert in the magic that is htaccess, I am wondering how to achieve the following.
I want any request to any files in folder/
to be redirected to the front page of the site index.html.I tried :
redirect 301 /folder/ http://blah.com/
redirect 301 /folder http://blah.com/
redirect 301 /folder/.* http://blah.com/but they seem to be trying to recreate the url by just missing out the folder name..
Any ideas ?
Ideally any sweet regex :)
- PSYKHO0
Not a pro myself by try this:
RedirectMatch 301 /folder/(.*) http://www.blah.com/$1
- bulletfactory0
RewriteRule ^yourfolder/(.*) http://www.yoursite.com/ [R]
- mikotondria30
aw bah, honestly I thought that would work, mr bulletfactory, but alas, no :(
- PunchDouble0
why not put an index.html in the folder that redirects
- HTACCESS does the entire domain (that you specify), so if someone hits it on a non-index page, it'll still force the redirect.thinblkglasses
- PunchDouble0
Redirect /yourfolder http://www.yoursite.com
- maximillion_0
RewriteRule ^yourfolder/ http://www.yoursite.com/ [R]
matches all by default
- nope : (mikotondria3
- then it depends on the order of your rules. most generic rules should go towards the bottommaximillion_
- stupidresponse0
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/thefolder
RewriteRule ^(.*)$ index.php [L,QSA]- oops, sorry, change .php to .html. got php on the brainstupidresponse
- mikotondria30
thanks, stupidresponse - I really thought that would work.
If you know that code definately would redirect requests for ANY file in the /folder/ back to the site's root index.html, then I guess something might not be set up correctly. That being said, might you know what that is.
I appreciate your response :)
- stupidresponse0
oh yeah, [L,QSA] will redirect without actually changing the visible URL, change it to [R]
i just tested it and it works locally here on apache 2
- stupidresponse0
if .htaccess is not working at all, check that AllowOverride is set to All in your http.conf file.
- Fizik0
holy, what is all this
don't need rewrite rules for that
REDIRECT 301 /folder http://domain.com/index.html
(or just to http://domain.com/)should work .....?
you had it in your tries there....
- stupidresponse0
a 301 redirect is "moved permanently", so it will try to append the file you are trying to hit onto the end of the redirect domain, so:
http://domain.com/thefolder/fileā¦
will redirect to:
- mikotondria30
ah thanks, each and all, I got it fixed..
RedirectMatch ^/myfolder/.* http://www.mysite.com
did the trick.