.htaccess not working
Moderator: General Moderators
-
tusharkale
- Forum Newbie
- Posts: 3
- Joined: Wed Dec 03, 2008 3:15 pm
.htaccess not working
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!!
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!!
Re: .htaccess not working
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
<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
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/
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/
Re: .htaccess not working
what file you want to redirect
one file or all files in the abc folders
one file or all files in the abc folders
Re: .htaccess not working
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.
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
Tassadduq: I want to redirect All the files in abc folder.
Re: .htaccess not working
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.
http://www.examle.com/abc
to
http://www.new_example.com/abc
so i sent the code to redirect the index page.
Re: .htaccess not working
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
link 1
http://www.seospring.com/2008/how-to-re ... -htaccess/
link 2
http://www.3ring.com/resources/3ring-bl ... -and-pages
Re: .htaccess not working
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.