.htaccess not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tusharkale
Forum Newbie
Posts: 3
Joined: Wed Dec 03, 2008 3:15 pm

.htaccess not working

Post by tusharkale »

I want to redirect all pages in my website directory to other URL. For that I have written a rewrite rule in .htaccess file.
This is directory structure
Website: http://www.example.com/abc

Say if any one visit any page inside abc I want it to be redirected to http://www.new_example.com/abc.

I have save a .htaccess file inside abc folder. But some how it is not working. Server is not reading it up or something is wrong.

This is my code
RewriteEngine On
RewriteRule ^(.*)$ https://www.new_example.com/abc

What is wrong in this? Is there any other setting that needs to be done?

Thanks!!
User avatar
Tassadduq
Forum Commoner
Posts: 60
Joined: Wed Dec 03, 2008 2:53 pm

Re: .htaccess not working

Post by Tassadduq »

simply remove all the code from your index page and just paste this

<body>
<html>
<META HTTP-EQUIV="Refresh" CONTENT="0;url=www.new_example.com/abc/index.php">
<title>Redirecting ...</title>
</head>
<body>
IF your browser doesn't redirect you automatically, please <a href="www.new_example.com/abc/index.php">click here</a>.
</body>
</html>




it will redirect your pages to http://www.new_example.com/abc
tusharkale
Forum Newbie
Posts: 3
Joined: Wed Dec 03, 2008 3:15 pm

Re: .htaccess not working

Post by tusharkale »

Thanks for the reply
But it will redirect only index page. If someone types in
http://www.example.com/abc/file.php then it wont redirect to http://www.new_example.com/abc/
User avatar
Tassadduq
Forum Commoner
Posts: 60
Joined: Wed Dec 03, 2008 2:53 pm

Re: .htaccess not working

Post by Tassadduq »

what file you want to redirect
one file or all files in the abc folders
User avatar
Syntac
Forum Contributor
Posts: 327
Joined: Sun Sep 14, 2008 7:59 pm

Re: .htaccess not working

Post by Syntac »

Tusharkale: Don't follow that advice; it's sloppy. Create a rewrite rule that redirects all requests into a single PHP file. Then have that file send the browser to where you want it to go, using header().

Also... Your current setup isn't working because rather than redirecting the browser, mod_rewrite sends the request to a file. Thus, said file must be accessible by the server.
Last edited by Syntac on Wed Dec 03, 2008 4:55 pm, edited 1 time in total.
tusharkale
Forum Newbie
Posts: 3
Joined: Wed Dec 03, 2008 3:15 pm

Re: .htaccess not working

Post by tusharkale »

Tassadduq: I want to redirect All the files in abc folder.
User avatar
Tassadduq
Forum Commoner
Posts: 60
Joined: Wed Dec 03, 2008 2:53 pm

Re: .htaccess not working

Post by Tassadduq »

sorry i thought you want to redirect like these

http://www.examle.com/abc

to

http://www.new_example.com/abc

so i sent the code to redirect the index page.
User avatar
Tassadduq
Forum Commoner
Posts: 60
Joined: Wed Dec 03, 2008 2:53 pm

Re: .htaccess not working

Post by Tassadduq »

tusharkale here are useful for you to solve your problem.


link 1

http://www.seospring.com/2008/how-to-re ... -htaccess/



link 2

http://www.3ring.com/resources/3ring-bl ... -and-pages
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: .htaccess not working

Post by pickle »

Ya, you want a redirect, not a rewrite. If you specify it's a 301 redirect, it'll update bots properly as well.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply