I have a website running on a dedicated server (Ubuntu - NGINX). Can anybody please advise me how to remove a particular extension from my url address. I have a splash page installed and when a person visits the site (www.mydomain.com) they view the splash page which has an address of www.mydomain/my-domain_splash.php. How do I remove the splash page extension and only have the www.mydomain.com displayed? I believe the answer lies in how NGINX redirects url, however, I do not what command to issue and where to issue this command to accomplish my task. Previously, when I utilized Apache as my webserver, my problem was solved through a simple redirect command placed in the root .htaccess file. NGINX does not utilize this .htaccess file, so my solution does not lay there. Contact with the splash page creator was already instituted and the creator could not provide a solution. Any help would be greatly appreciated. |
Any webserver will do that and with any page. It has nothing to do with redirection. You need to understand how the process works and why you normally do not see index.php or index.html shown on the url.
For example. On a default configuration if you go to yourdomain.com the webserver will load up either index.html or index.php. It's not shown on the url because the webserver is treating those pages as a index page. It will load that page even tho it was not specified on the url.
However if you deliberately specify index.php on the url then it will show index.php in the url anyway even tho it is set as a index page. Thats how it works, and it has nothing to do with redirection.
In your case, in order for the splash page to be shown only to guests, there was something that was configured as part of the install of the splash page to specifically redirect the user to that specific page. In other words, it was deliberately specified as part of the url.
The solution will be two things you need to do.
First. You need to configure the webserver to treat splash.php as a index page, and because you have a index page already there, index.php, you need to make sure that splash.php is listed first in the list of index pages. I cannot tell you how to do that in NGINX. I use apache, but all webservers have index page settings.
Second. You need to change the code that handles the redirect to the splash page to redirect to / and not to splash.php. Dispite what you may think, you cannot do that redirection in the webserver. It is done in the code of the site already, and has to remain in the code of the site. You cannot override it in the webserver.
I know you have stated your convinced it has to do with NGINX redirection, but you are incorrect. It does not. Thats not how the splash pages work. Or how index pages work.
Now this may also cause another problem. To get splash.php off the url it has to be specified as a index page and will have to be first in the list. Now this will create a problem. The splash page will need to be changed to redirect all logged in members to index.php. But now this will reverse the issue. Instead of splash.php showing ip in the url, index.php will when a member is logged in.
You can't solve one problem without creating another. In order for the page not to appear on the url it has to be a index page, yet you can't have more than one index page per folder because the web server will always load the first one it finds from the list. So one of them will always appear in the url. You can't configure it so neither of them do. It does not work that way.
That's why no one as done this. Because of the reverse effect it has, it just is not worth the trouble.
https://www.deanbassett.com |
Ok excellent. Thank you for the info and correction. I will investigate this further. |
Ok excellent. Thank you for the info and correction. I will investigate this further.
I made some updates. Please re-read. I forgot about the reverse effect it will have on the normal index.php, so i edited my post to mention it.
https://www.deanbassett.com |
Question Deano. If I were utilizing Apache, would you know how I could accomplish this task... Could you outline the specific procedure? |
if you will look in nginx.conf (or whatever you named the configuration file) you will see where to add splash.php to the list of indexes.
However, I don't understand why you are so worried about the URL that is displayed in the address bar. Walk around the net and see all the strange URLs showing up. People don't care about the URL in the address bar, they look at the page that is presented.
Wait, I think I now know why you want this changed. The URL you are seeing is http://your_site.tld/developer_splash.php. I can understand why you would not want the actual splash module you are using to show up. Developers should not force branding onto the products they are selling in the market forcing buyers to more or less advertise for them or to shout out to anyone what the module is; also could be a security issue since if a know security bug exists now anyone visiting the page knows you are using it. Developers should make their templates and splash pages brand free; or at least provide an unbranded product for a bit more in cost.
You can probably remove the developer's name/brand from the name of the file; not sure the extent of changes that you might need to do. I would contact the developer and ask for an unbranded splash page; one in which he/she is not shouting out to the world that you are using their splash page code.
Geeks, making the world a better place |
Not really. The apache part is easy. In apache there is a DirectoryIndex setting that can ether be put in the apache config or it can even be stated in the .htaccess file.
But your not using apache.
Also changes may be needed with the splash page and because every splash page is different, different code, there is not way i can even begin to tell you what to change there.
I am guessing you do not care that making these changes will cause index.php to always appear in the url instead of splash.php
https://www.deanbassett.com |
Nginx:
server { index index.php;
in front of index.php place splash.php making sure to use the exact name of the splash php file.
Geeks, making the world a better place |
@Geek Girl - no good error produce - NGINX will not reload specified parameters. Does not like the splash.php command. |
It's not a command, it's a setting.
Show what the config line looks like now. Has to be a error.
Also. is it splash.php that shows up it the url or something more specific? If the url for the php page does not read exactly as splash.php then you need to use what it actually is.
https://www.deanbassett.com |
@Deano. It was an error and it prevented the successfully restart of the NGINX server. I attempted the to add the actual splash.php extension which was xxx_splash.php and I attempted plain old splash.php to the NGINX config file; however, to no avail. |
Your URL is http://domain.tld/xx_splash.php
So you would use xx_splash.php in the list of indexes.
This is what you sent to me in PM; with your information redacted. I added the splash to the index. There may be something outside of this server entry that is causing a problem if you did what is shown below.
server { listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6
access_log REDACTED; error_log REDACTED;
root REDACTED; index xx_splash.php index.php index.html index.htm;
location / { try_files $uri $uri/ /index.php?q=$uri&$args; } # Make site accessible from http://localhost/ server_name REDACTED;
# use fastcgi for all php files location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
# deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } }
Geeks, making the world a better place |
@geek girl.... does not work. still display splash.php link. |
Geeks, making the world a better place |
If you want to play with if:
# This will redirect index.php index.htm to /
# Feel free to add other extension you need
if ( $request_uri ~ "/index.(php|html?)" ) { rewrite ^ /$1 permanent; }
and for example:
server {
# other stuff such as server_name, access_log, etc
# Here goes the code
if ( $request_uri ~ "/index.(php|html?)" ) { rewrite ^ /$1 permanent; }
One really shouldn't use if statements in Nginx. Note that you don't need the html and of course index would be xx_splash.php.
Geeks, making the world a better place |
@geek girl.... does not work. still display splash.php link.
Of course it will. In case you have forgotten, and i guess you have, i mentioned a second step that has to be done.
The splash page coding has to be changed. During the install of the splash page something had to be modified to redirect non members to the splash page. That has to be changed to direct them to just the domain name only without the splash page name. The splash page also has to be change to redirect logged in members to the index.php page.
You did not read all of my message on this describing what needs to be done. The server change is just one change. The rest is changes to the script. You can't redirect using NGINX alone. It will not work. The redirects in NGINX and the redirects that are already built into the splash will fight each other resulting in a endless bouncing that will eventually cause a redirect error.
https://www.deanbassett.com |
Instead of all this work, change the module so that the xx part is not displayed, so you just have http://domain.tld/splash.php. I don't know how much you paid for this but my previous rant still goes. You should not have to advertise where the module came from. Contact the splash developer and tell her/him you want their splash to just say splash.php in the URL.
And to anyone else reading this thread, perhaps you would like to think about such things before spending a lot of money on a splash or template. As it stands now, the splash developer would not get a pence of my money with his moniker visible in the URL. There is no need for it, it does not add any value to the end user. Developer, how would you like it if you purchased Office and every print-out contained Microsoft Office across the top of the page?
Geeks, making the world a better place |