Server Rewrite for lowercase from uppercase issue - .htaccess

My hosting company is telling me: On our platform the folder names are case sensitive. Unfortunately, it is not possible to access the folder name test using TEST and vice versa.
My issue is: if a url request "www.domain.null/TEST/" is entered and the folder has a lowercase like "www.domain.null/test/ - it is not possible for a htaccess rewrite to change the request to lowercase correctly, is this an accurate statement?
Is this an issue with my host or ALL hosting companies? DO i need to do a redirect for ALL uppercase possibilities to the lowercase urls for my site?
Thank You

Related

URL Rewrite IIS7 - Get only first directory after .COM

I wanted to implement an redirect rule in IIS 7.5 which checks only first directory after .COM.
E.g.
1. http://www.test.com/ABC , Here i need to get only ABC and pass to other page as query string.
http://www.test.com/ABC/XYZ - Skip
test.com/ABC/Home.aspx or any other file - Skip
Can anyone provide your valuable suggestion.
Thank You

redirect non existence url to folder

i am a user, and i type: www.japsomething.com, that url doesn't exist however there is a folder called "something" and i want this url to point to that folder?
do i need to purchase the domain name for this to work or i can use .htaccess?
i still would like to preserve the url. so this means, even though i am coming from
www.japsomething.com the url should still say www.japsomething.com and when i click anything on the site it should say www.japsomething.com/anything/
another question is, how can i detect based on the users ip that i want to show them a spanish site, or an english site?
thanks for your responses.
do i need to purchase the domain name for this to work or i can use .htaccess?
You need to purchase the domain name, because otherwise when someone types: www.japsomething.com, their DNS is going to try to look that name up, and if you don't own that domain, the request is never going to reach your server, thus, your htaccess file is never even used. Because you don't own every domain that starts with "jap" and ends with ".com", you can't use htaccess to do this.
i still would like to preserve the url. so this means, even though i am coming from www.japsomething.com the url should still say www.japsomething.com and when i click anything on the site it should say www.japsomething.com/anything/
If you own the "japsomething.com" domain, you simply point it to the server and directory that contains all the content, and then be done with it. No htaccess trickery is involved here. If you went out and bought the "japsomethingelse.com" domain, simply point it to the directory that serves that.
another question is, how can i detect based on the users ip that i want to show them a spanish site, or an english site?
See mod_geoip2 for downloads and examples.

.htaccess changing domain but not the rest of url

I'm out of ideas to achieve the below:
I host 2 websites "A" and "B" on one server, as most of their elements are common.
"B.com" is web forwarding package - it forwards the user to "A/indexB.php".
All I want to achieve is when someone enter the "B" url it redirects to "A/indexB.php" document, but the "B" domain should remain.
I can't use "B" as Masked Redirection Type, as people browsing the "B" website instead of seing links like "B/link" they would see only "B".
Is there any .htaccess solution?
If "B" redirects to "A/indexB.php" then where should redirect "B/link"?
I'm not an expert, but it seems that you're trying to adapt global redirect (based on domain -- i.e. redirect everything from B.com) to a specific targed (script A/index.php). I'm not pretty sure, if this is possible.
I would consider using server / hosting configuration for defining a permanent redirect between "B" and "A". Or even would think about configuring "B" domain as Addon Domain (which can point to a particular path in your account, not only root). But this again returns me to the question in first line and I'm a bit confused, if it is possible, what you want to achive?

Get rid the slash in URL (ex. something.com/dogs)

I recently purchased the domain name simply.do. I want to use it as a URL shortening service, but I don't like have to do simply.do/something. Can I remove the slash or replace it with a difference symbol?
If this helps, I am using a server running Nginx and I will not switch to Apache.
Thanks!
I would also appreciate any feedback on the domain name. I was hoping to sell simply.do/insurance, simply.do/religion, etc. to various companies. Do you think there is a way I could sell these parts on an auction website? Thanks!
When you visit simply.do, that refers to simply.do/index.php (if you use php in background).
So, you can use it as query, for eg, simply.do?insurance will lead to some long url like ://a-long-domain-name/a-long-list-of-directories.
Use server script to get the value after ? mark so that if someone visite simply.do?insurance, it will be like simply.do/index.php?insurance. It works with all browsers.
You can obtain the value from the $_SERVER['REQUEST_URI'] OR $_GET[] array, check if the query string: 'insurance' is in your db or not. If yes, redirect the user to required site.
You need to know how the HTTP protocol works here, to better understand what you are doing. If you want to sell the URLs, you need a basic URI handler for /insurance, or /religion. You can also sell insurance.simply.do, If you want to, thru' DNSes and default VirtualHost handlers.
This answer is irrespective of the server used.
You cannot remove/replace the / right after simply.do since it delimits the host and the path in the URI.

.htaccess and sessions for security?

In my application users have their own "websites" which can be reached if they are signed in.
However, since these websites are just directories containing html and other documents everyone in the world can reach them if they know the address. I can't have that :) A user should be able to decide whether or not thw world might see their files or not.
Can I use .htaccess to activate a PHP-script every time a request is made to that directory?
I.e. if reqested-site is "/websites/{identifier}", run is-user-allowed-to-view.php?website={identifier}
The identifier is a numeric value which refers to both a physical folder and a post in the database... and the script would then return true or false.
Or is there perhaps another way of solving the same issue?
Cheers!
You can use mod_rewrite to rewrite requests with such a URL internally to your script:
RewriteEngine on
RewriteRule ^website/([0-9]+)$ is-user-allowed-to-view.php?website=$1
But this rule is only for the URL path /website/12345 and nothing else.
Or have every page as a PHP page and just put at the top a single line to redirect if the session / cookie is incorrect or not set. Obviously wouldn't work for non-PHP content such as images.
What you need is a proper front-end (written in whatever language). You need to have your web-server (Apache in your case it seems) pass the requests to the said front-end.
You cannot do what you are asking for with just .htaccess files.

Resources