htaccess not working with ~username Path - apache

I am working on a new website, which still has to be connected to a domain name via DNS. So, at the moment I am working with http://ipaddress/~username/public_html/
I am having a problem with making internal redirects work in my htaccess file, which sits at http://ipaddress/~username/public_html/
I need to map http://ipaddress/~username/public_html/work/ to http://ipaddress/~username/public_html/projects/index.php
Here is what I have:
RewriteEngine On
RewriteBase /~username/public_html/
RewriteRule ^work/?$ projects/index.php?$1 [L,NC]
The problem is that I always get a 404 error with the above.
How can I make this work properly?
UPDATE
This seems to have to do with how the server handles the redirects if a DNS record does not exist yet. In other words, since this is a development site, a domain has not been connected with the site. Once that has been set up, everything is working.

This seems to have to do with how the server handles the htaccess redirects if a DNS record does not exist yet for the site. In other words, since this is a development site, a domain has not been connected with the site and relative paths were used. Once that has been set up, everything is working.

Related

301 Redirect Still Happening even though its been removed

I am having trouble with some old 301 redirects.
They have been removed from the htaccess but still seem to be working.
Some of the redirects have been removed for over 1 year but they still redirect as if they are present.
Ive tried different browsers/private browsing, restarting apache, flusing caches on the cms system and no luck.
The 301s were set out like this
Redirect 301 /example.com http://www.example.com/new-url
Our CMS is magento
Check if you have same redirects in Magento catalog rewrites (just a guess). Post your complete htaccess and give a real example of redirect. It can also be caused by custom varnish vcl (but very rare)
I fixed my issue by looking for other htaccess files in the ftp and found that an old htaccess had made its way into the root of the ftp which was conflicting with the correct one.
This was acting as a back up htaccess to the correct one and redirecting old URLS still.

Htaccess subdomain exceptions to rewriterule

I host in siteground, on a multiple domain account,
Main domain is pointed to public_html, so it's a bit dangerous for the rest of sites in the account to use it (unwanted deletes, hacks, and so...)
I successfully followed this guide (http://www.ianholden.com/how-to/hide-joomla-subdirectory/) to point mydomain.com to midomain.com/mydomain folder (joomla install)
But now I have a problem with existing subdomains for sites still without their own domain names, that give a 500 error when visited...
What could I use to leep my current rewrite rule mydomain.com -> mydomain.com/mydomain and make exceptions for subdomains as whatever.mydomain.com?
Thanks
The problem is that the rule that you have added to your .htaccess file will affect all other sites on your hosting account, since the .htaccess file is at the same level of all those sub-directories.
If you have too many sites hosted this way, then I suggest you go with a VPS, and then create an account for each and every domain that you have. This will ensure that your websites run smoothly and in silos.
Whatever you do to make Joomla work properly under a subdomain, will create problems for you on the long run.

Is there an Apache/Plesk server setting that governs https:// behavior?

Context:
I've recently moved a site to a new host, and moved the SSL certificate from the old host to the new one. The code, written in PHP, is a big mess made by someone no longer available many years ago. Because of this, I'm hoping to figure out something related to the configuration of the server that can fix the issue so I don't have to reverse-engineer the rather messy code.
Problem:
When users navigate to an area of the site that uses https://, all goes according to plan. The problem, however, arises when they click a link in the navigation that is normally to an http:// part of the site. On hover, you can see that the target URL incorrectly includes "https://". When the user tries to go to a non-secure area with https:// in front, either by clicking one of those altered links or by typing it into the location bar of the browser, they are redirected to the directory without any domain. For example, if you try to go to "https://domain.org/site/", the browser is redirected to only "/site", which of course cannot be found.
Theoretical solutions:
Is there a setting in Plesk which governs the "stickiness" of https? One way to fix the problem is to stop the non-secure links from acquiring https://.
Is there an obvious reason why whatever script or file the site is using to redirect would break when an un-secure area is accessed via https://? Is there a server setting that would have made this function differently on the new server via the old server?
I don't have access to see what exactly the configuration of the old server was. Is it likely that this could be caused by a difference in PHP version? If so, any suspicions about what the problem would be?
Is there some workaround with .htaccess that can manually redirect all but certain secure areas of the site to http:// when they are accessed via https://, presumably before the site's redirect script is activated?
Thank you for any help!!
Yes, since Plesk 17 (Onyx):
For older versions you can create .htaccess files which will rewrite request from https pages to http, based on referrer:
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^https://domain.org [NC]
RewriteRule ^(.*)$ http://domain.org/$1 [L,R=301]

Apache htaccess redirect

about a year ago, I moved a whole website to a new server. I still have access to the old server (which has a lot of junk on it) and I would like to have the old site redirect to the new one (they have different domains). The old server is running Apache. I thought something like this could be done via the .htaccess file so I put the following as my .htaccess file:
Redirect 301 / http://newsite.com/
This did not work and, upon accessing the old site, I got a "500 Internal Server Error".
I would rather delete the files from the old server. The problem is, though, that I am afraid that (since they are ranked pretty high on Google) if someone clicks on a link to one of those files, he will just get a "404 File Not Found Error". I just want to edit the .htaccess so that every file path on it will redirect to the new site. If you know how to do that, please help me. Thank you!
You should consider using mod_rewrite instead, assuming it is enabled on the old server:
RewriteRule ^(.*)$ http://newsite.com/$1 [R=301, L]
This preserves and appends the path to the new host

Add on domain mod rewrite to create pretty url

I have a main website www.site.co.uk and one of my add on domains is addon.co.uk. Site has an htaccess as does addon. The folder of which from the root would be www.site.co.uk/addon.co.uk/.htaccess ..I think!
Anyway currently I can do redirects within addon htaccess file fine, but its a database driven site and im trying to create pretty urls for it, so:
http://www.addon.co.uk/addonsites/some.php?id=page
would become:
http://www.addon.co.uk/id/page/
The mod I have in the addon htaccess file is the following:
RewriteEngine On
RewriteRule ^id/([^/]*)/$ /addonsites/some.php?id=$1 [L]
But this has no effect.
Well, the mod_rewrite module will perform translations on requests to the server, so when anyone requests the resource located at http://www.addon.co.uk/id/page/ the server will know that http://www.addon.co.uk/addonsites/some.php?id=page is the place to go.
However, mod_rewrite does in no way modify your existing links. I.e., you should rewrite the HTML (or scripts generating the HTML) to match the "new" way of linking. E.g., if you have ... somewhere on your site, you must make sure it is changed to ....
tl;dr
mod_rewrite handles incoming requests; it does not modify your output (HTML).