Website redirect (.htaccess) [duplicate] - php

This question already has an answer here:
Redirect all requests to subdirectory except a few ip addresses
(1 answer)
Closed 8 years ago.
I need to put a important client's website into maintenance mode. I want redirect (or serve a static html) all vistors except 2 IPs so we can continue to access the website while we work on it.
Is there a way to do this with a .htaccess file?
I known I could easily do this with php and headers but I will be working with the PHP code a lot, so many of times the users will get a PHP error before getting redirect.
Also, Google bot visits this website very often. Is there a way to tell bots that the website is temporary down so they don't index the "Please come back later" massage? (a header code maybe?)
Thanks

Here is a great article from SEOmoz
http://www.seomoz.org/blog/how-to-handle-downtime-during-site-maintenance
It is a nice step by step explanation and I think it is just what you are looking for. It tackles the SEO side of things and also explains how to use your htaccess to serve the proper HTTP status code.

# Redirect old file path to new file path
Redirect /olddirectory/oldfile.html http://example.com/newdirectory/newfile.html

Related

Google Adwords Detecting "Malware" in Nonexistent Pages

I've been trying to figure this out for a while now. Google Adwords is requiring that we remove malware from my client's website, and we finally got them to send us a list of which URLs are affected.
They listed three .html pages, none of which exist on my client's website because all of them are .php. I think they are URLs from the previous version of the site, which was removed from the server a couple years ago...
Can anybody point me in the right direction to get this resolved for my client?
FYI: hosting is through Fatcow.

Permanent URL masking for mirroring website using php and htaccess

First
Let say that i have www.domain.com that are client site and user login and do all the thing that he want (site is main and he use POST method for login adn other things and HEADER redirect if login are success)
But i not want user to see original www.domain.com i want when they enter www.name.com/dashboard.php to see content from www.domain.com/dashboard.php but him URL bar to show www.name.com/dashboard.php ..and like this all other page that can have original www.domain.com
I found this site:
http://www.htmlremix.com/css/permanent-url-masking-for-mirroring-website-using-php-and-htaccess
Adn use script but when are entered user login detail noting happen!! Just home page reload.
I try everything that i think may be cause problem and not found how to solv it .. So please help me!!
Thanks Allot
P.S. If have some more good way that can i use also will help me!
that cant be achieve with a htaccess file.
You need different things.
possible solution could be:
apache mod proxy so you could proxy everything through that url.
the other way could be a php written some kind of proxy. Working with curl or and remote configured fopen.
But be careful to also send the post data and the cookies, otherwise the user session could not be handled if its cookie based.
If both domains are on the same server you could easily set this up with a vhost configuration in apache/nginx what ever you are using.

Vanity URLS & Xampp

I understand that there may be other questions regarding vanity urls but everyone i see has a different code that i guess does the same job. Therefor i do not understand what rules are best for my personal question, that being said here is my question.
I simply want to create this,
127.0.0.1/website/profile.php?id=1
To this,
127.0.0.1/website/profile/Admin
My sub questions are also,
I understand the .htaccess file has to be in the root directory, but is that the root of my website or my xampp htdocs?(e.g c:/xampp/htdocs/ or c:/xampp/htdocs/website)
Using php should i make the conversion between id to username for the URLS on a seperate file then redirect to the requested user's page?
Thank you for reading, i just can't seem to get my head around .htaccess!
Root directory of your website.
No need for redirects. The way it works is that you can map every section of your URL to a URL parameter. For example, http://localhost/profile/Admin is really interpreted as http://localhost/website/profile.php?username=Admin. Only users will see the vanity URL; PHP will still see the URL parameters. In your case, the .htaccess rule will look something like ^profile/([0-9]+)$ profile.php?username=$1 (I obviously don't know for sure since I don't know the architecture of you site).
On a side note you might find Virtual Hosts interesting. It's a way of being able to create your own local domain for your site, for example http://my-local-website instead of using http://localhost/website or waiting to test in production.
More info here: http://sawmac.com/xampp/virtualhosts/

What .htaccess redirection has effect on Google bot?

I made one website xyz.com using php codeigniter framework. This website has modules, so modular extension is used. Now when this website is made live, every link shows index.php. So for this we can use .htaccess for modrewrite command. Till now my knowledge was cool enough. Now when my friend who has good knowledge of SEO saw my website links, he told me that your website will not come above(lower ranks) in google.
His reason is - your every request is pased through index.php. When google crawls your site, it will be redirected again to index.php which is main drawback. As he didnt have much knowledge about codeigniter, he told to fix this index.php issue as soon as possible. So I wanna know
IS HE GIVING A VALID REASON?? if yes...so how can I solve this problem.
Anything related to this issue from your side is also welcomed, as I may not have asked complete question.
Well, after your comment I can say that your friend is wrong. Google bot will never be redirected on the same page (index.php in your case). Of course is not very good that in each page url you have the "index.php" because you are losing important chars which otherwise can be used to put keywords.
Said that, your site will be indexed normally. Infact, many Joomla-based websites have the same behavior as you can see on this website (parlaritaliano.it) which is very well indexed on Google.
Anyway, I advice you to replace (using .htaccess) the index.php in every of your urls because it is better from a SEO point of view. I repeat...better, it does not will cause any Google bot loop.

Firefox has detected that the server is redirecting the request for this address in a way that will never complete [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am trying to develop a job site using jobberland scripts.
But on connecting to server the following error shows on all the pages in Firefox:
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
Can You help me with the fix please. Is the problem with scripts or with databases (as some sites have explained while I searched on this query).
https://shopplugin.net/kb/checkout-redirect-loop-when-https-environment-variable-is-not-set/
Known Cause
Some hosting environments do not declare that they are running securely in a standard way (or at all in some cases). This will cause issues with the is_ssl() to not be set properly. Shopp see’s that SSL is required and then checks for SSL. If is_ssl() is not set, Shopp will attempt to redirect to HTTPS. Thus creating a loop.
The Solution in the link is only for wordpress, but if anyone knows of a generic php fix, please advise!
This might happen sometimes due to clogged session ( rather invalid cookies in your browser ) or also because of the redirection feature used in server.
Say for example, the user access Page A, the server might ask the browser to redirect to some Page B by passing on some headers; and based on headers the browser might redirect to a Page B which in turn redirects back to Page A. And it goes on creating an indeterminate loop.
To solve you can try the following:
Clear your cookies in your browser
Check the session management and redirection mechanism which you have developed
Try to clear the server session variables and retry.
Hope it helps!!!
There's an endless loop (or circular references) caused by HTTP redirection somewhere in the scripts.
Like stillstanding said. You have an endlessloop caused either by your php script or by a rewrite rule in your .htaccess or even caused by both.
For example you have a userlogin and if the user is not logged in you redirect any page to /.
In index.php you check if the user is loged in and if not you normaly redirect to /login.php BUT lets now say you made an error and put a /user.php there so that user.php redirects to / because the user is not logged in.
I had this same issue with a PHP page I was working on. While checking how it rendered in various browsers I got this weird error. I was never able to determine what caused it, the page loaded fine in IE9 + Opera, but gave this error in Firefox. The script checked for a stored cookie and showed a link based on it, but I wasn't using any redirects or sending any headers from the script. When the cookie was present in Firefox I got this error, when it wasn't the page loaded fine. Even after deleting and re-writing the cookie same thing. I removed Firefox and reinstalled the latest version and the error stopped popping up, so it seemed like something to do with Firefox handling the cookie although I have no idea why.

Categories