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

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.

Related

URL redirect when accessing domain

is the first time I'm using IIS (Windows Server 2019) and I'm looking for a configuration to be able to redirect clients from http://mysiteExample.org/ to http://mysiteExample.org/embed.html?key=val. I considered that URL Rewrite Module could help me to achieve this (as is not necessary for the clients to see the new URL they'll be redirected to). I made the configuration as shown in this screenshot, where I set '^$' as a pattern to specify this should apply for cases where no URL string is provided.
Could somebody with more experience advise me on how to achieve what specified above?
Thanks in advance
I finally managed to make it work changing the action type from 'Rewrite' to 'Redirect'.

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.

Symfony2/ get variable from subdomaine and htaccess

I using Symfony2.
What would be the best practice to get a variable from URL. I am using subdomain to get the city.
Ex: paris.website.com
how do I get Paris as variable.
I believe I need to play with Kernel and htaccess, but I haven't figured out how.
Thanks if you can put me on right tracks about that.
Cheers,
Pierre.
You should read the documentation of Symfony. One of the basis components of Symfony is the Routing that provides exactly what you need :
www.mysite.com/paris/
Using the subdomain is not the solution, but you can play with .htaccess to rewrite subdomain paris.mysite.com to www.mysite.com/paris (if web server allows it) after having configured your route in Symfony.

Custom URL in Codeigniter using htaccess

I am developing a site on Codeigniter 2.0.2 . Its a site where companies/users can signup and create their own profile page, have their own custom url(like http://facebook.com/demouser), have their own feedback system, display their services.
This said, I have been successful in display the profile page in the following format
http://mainwebsite.com/company/profile/samplecompany
This displays the home page for the company samplecompany , where company is the controller and profile is the method.
Now I have few questions,
I guess it is possible to create to have/get http://mainwebsite.com/samplecompany using htaccess and a default controller. If anybody can help with the htaccess rule , that would be awesome. I am already using htacess to remove index.php from CI but could not get this working.
There will be few other pages for the given user/company such as feedback, contact us, services etc. So the implementation links that come to my mind is of the form
`
http://mainwebsite.com/company/profile/samplecompany/feedback or
http://mainwebsite.com/samplecompany/feedback
http://mainwebsite.com/company/profile/samplecompany/services or
http://mainwebsite.com/samplecompany/services
http://mainwebsite.com/company/profile/samplecompany/contactus or
http://mainwebsite.com/samplecompany/contactus
wheresamplecompany` is the dynamic part
Is it possible to create site links in the format?
I understand using A record for a given domain, I can point a domain say, http://www.samplecompany.com to http://mainwebsite.com/company/profile/samplecompany so typing http://www.samplecompany.com he should be taken to http://mainwebsite.com/company/profile/samplecompany . If this is successfully implemented, will
http://www.samplecompany.com/feedback
http://www.samplecompany.com/services
http://www.samplecompany.com/contactus
work correctly?
I guess it is possible to create to have/get http://mainwebsite.com/samplecompany using htaccess and a default controller. If anybody can help with the htaccess rule , that would be awesome. I am already using htacess to remove index.php from CI but could not get this working.
There will be few other pages for the given user/company such as feedback, contact us, services etc. So the implementation links that come to my mind is of the form ` http://mainwebsite.com/company/profile/samplecompany/feedback or http://mainwebsite.com/samplecompany/feedback
You can accomplish this using routes. For example, in your /config/routes.php file, put this:
$route['samplecompany'] = "company/profile/samplecompany";
$route['samplecompany/(:any)'] = "company/profiles/samplecompany/$1";
The first rule tells CodeIgniter that when someone accesses http://mainwebsite.com/samplecompany that it should process it as if the URL were "company/profile/samplecompany". The second rule captures anything that comes in the URI string after "samplecompany" and appends it onto the end.
However, if you have multiple companies(not just samplecompany), you're probably going to want to extend CI's router to suppor this unless you want to manually edit the config file each time a new company is added.
OK, you're definitely going to want to handle dynamic company names(as per your comment). This is a little trickier. I can't give you the full code, but I can point you in the right direction.
You'll want to extend CI's router and on an incoming request query the DB for the list of company names. If the URI segment matches a company name, you'll want to serve it up using your company/profile method. If it does not, you will ignore it and let CI handle it normally. Check out this post on this topic for more information: forum link.
Here's a great guide on how to achieve what you need: Codeigniter Vanity URL's.

.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