Hiding page name following site URL

This section is for posting questions which are not directly related to WYSIWYG Web Builder.
Examples of off topics: web server configuration, hosting, programming related questions, third party scripts.

Note that these questions will generally not be answered by the administrators of this forum.
Post Reply
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Hiding page name following site URL

Post by alex4orly »

Hello folks,
I have several websites that are made with RWD in mind, for example here : http://www.nmaa-rc.org.au
But once the site loads, the visitor can see the actual page name he / she is on - in this case it is "frontpage.html"
I have one site, that has not yet been converted to be based on RWD here : http://www.semac.org.au/ which doesn't show the pages.

How can I avoid showing the pages?

The main reason for this, is that I want to implement Login / password control and visitors will know the page name that loads after the login dialog and circumvent it by going directly to it...

Any suggestions?
User avatar
Pablo
 
Posts: 21508
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Hiding page name following site URL

Post by Pablo »

This has nothing to do with RWD.
The pages are displayed in an inline frame, so that is why the URL is not updated.
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: Hiding page name following site URL

Post by alex4orly »

Ok, is there a way for me to hide the page names from showing up on all my other sites?
User avatar
BaconFries
 
 
Posts: 5316
Joined: Thu Aug 16, 2007 7:32 pm

Re: Hiding page name following site URL

Post by BaconFries »

If you are not going to be calling the pages in a iframe (inline Frame) like you have shown, then you can hide the file extension ie .index.html etc by using a . htaccess for this. And if the page (s) are protected then the user/visitor won't or shouldn't be accessible unless they login.
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: Hiding page name following site URL

Post by alex4orly »

Hello again,

1) Never touched . htaccess
2) What does it mean my pages are protected

Can you please elaborate with an example?

Thaks
User avatar
BaconFries
 
 
Posts: 5316
Joined: Thu Aug 16, 2007 7:32 pm

Re: Hiding page name following site URL

Post by BaconFries »

1) Never touched . htaccess
A .htaccess is really just a text file to create simply open note pad and paste the following

Code: Select all

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html[NC,L] 
to save -> Save As -> Write .htaccess and choose "All Files" as the type - this will then create the .htaccess file for you now upload to your host. Note your host/server must support Apache.

Image
2) What does it mean my pages are protected
It means are they protected! can I for instance access the page without having to login? If I know the url can I just type this in the address bar and enter? If the page is protected ie the Page Protect Object then I shouldn't be able to access without logging in first with credentials. You can read more at the following:
Step 4 - Protecting a page
Adding a login to your web site Note Alex you have asked about Page Protection before.
See the following this is a little programme made by a member.
Extensionless URLs
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: Hiding page name following site URL

Post by alex4orly »

Hi Baconfries,

Seems a bit of missunderstanding here. What I want is that:
1) Visitors that know the page names of the website, may be able to circumvent the Passowrd / login dialog and access those pages directly.
2) To prevent this, I want to hide the page names, so whatever page the visitor visits - the URL will remain the original URL : http://www.beleuramyhome.org.au/ whereas now it shows the pagename.html on the continuation.
3) I thought that maybe there is a way of making an entry (What?) into .htaccess to prevent this from showing.
Yes, I did ask about page protection, but I have no intention to implement such a feature - this will be a duplicate to implementing a global login page on initial entry to the site.

If there is a way to fix this in .htaccess, please help me with that

Thanks again
User avatar
BaconFries
 
 
Posts: 5316
Joined: Thu Aug 16, 2007 7:32 pm

Re: Hiding page name following site URL

Post by BaconFries »

By inserting the following into your .htaccess file this will then remove all of the file extension(s) that end in .html including the page name(s) as in this example pagename.html If you carefully look at the code below you will see that it is using .html. When on the server it will know to remove this from all pages that use .html Please note that this is a server configuration that your host can offer support on.

Code: Select all

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html[NC,L] 
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: Hiding page name following site URL

Post by alex4orly »

OK, so let me see if I understand

1) For each page I want to hide, I need to insert those 2 lines ? or the first line is required only once followed by a list of several pages???
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html[NC,L]

2) As per the above example, in my case (frontpage.html) it will be
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $frontpage.html[NC,L]

3) Does it matter where in the .htaccess file the lines are inserted
4) Is it also possible to hide pages if they are of type PHP files

Thanks again
User avatar
BaconFries
 
 
Posts: 5316
Joined: Thu Aug 16, 2007 7:32 pm

Re: Hiding page name following site URL

Post by BaconFries »

1) For each page I want to hide, I need to insert those 2 lines ? or the first line is required only once followed by a list of several pages???
No, you only need one .htaccess file this will cover all pages!
2) As per the above example, in my case (frontpage.html) it will be
No, you only need the extension (.html, .htm, .php) nothing else the server does the rest and removes the name plus the extension!.
3) Does it matter where in the .htaccess file the lines are inserted
If you are using other references in a . htaccess already then I would place at the start.

Code: Select all

<IfModule mod_rewrite.c>
RewriteEngine on
in your .htaccess place here
</IfModule>
4) Is it also possible to hide pages if they are of type PHP files
Yes, you can see the following

Code: Select all

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
#RewriteRule ^([a-z]+)\/?$ $1.php [NC]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html
#RewriteRule ^([a-z]+)\/?$ $1.html [NC]
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: Hiding page name following site URL

Post by alex4orly »

Thanks again,
Now the big question is - if my host platform supports this
Cheer
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: Hiding page name following site URL

Post by alex4orly »

Not working... Please visit : http://www.beleuramyhome.org.au/ - all the page names are showing on th eURL
The content of my .htaccess is below, as copied from your instructions...
What am I doing wrong???

I placed .htaccess file into the root of the site, should I place it into the public_html folder instead, where the actual site pages are loaded into? ?

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
#RewriteRule ^([a-z]+)\/?$ $1.php [NC]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html
#RewriteRule ^([a-z]+)\/?$ $1.html [NC]
</IfModule>
User avatar
BaconFries
 
 
Posts: 5316
Joined: Thu Aug 16, 2007 7:32 pm

Re: Hiding page name following site URL

Post by BaconFries »

Does your host support Apache? Have you named the htaccess just .htaccess with no other extensions such as maybe
.htaccess.txt? Note I am in the UK so there is a time difference and I am turning in now so won't read/reply till the afternoon.
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: Hiding page name following site URL

Post by alex4orly »

Yes, I know where you are
Yes, the filename is exactly that
Yes, the host company is supporting it
Is the content correct?

Go to sleep
User avatar
BaconFries
 
 
Posts: 5316
Joined: Thu Aug 16, 2007 7:32 pm

Re: Hiding page name following site URL

Post by BaconFries »

Yes from looking at what I gave you to use it looks ok. When you uploaded the .htaccess you need to ensure optimal the file is in 'ASCII' mode and not 'BINARY' many FTP software programs use 'BINARY' as default so this may be the issue if it wasn't the correct format.
Does it appear in your file listings? have you uploaded it to the directory you wish it to take effect on? you can check this by using your web browser to see that it has worked. If it doesn't show then that is fine it just means the server is hiding it or your 'FTP' is.
Have set permissions to the file correctly? if not try setting to '755' or 'executable' this can be done using 'File Permissions' or using 'CHMOD' entering ' 0755'. If after this it still doesn't work contact your host asking if .htaccess is enabled as many do not use and if not enabled can they do so.
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: Hiding page name following site URL

Post by alex4orly »

Hello again,

Yes, uploaded it as ASCII
Yes, .htaccess is visible
Yes, the Host company assured me it is supported
Yes, it is in the folder where I need it to do it
Yes, changed the permissions to 755

The host company send me a link to Stackoverflow to search for information

But - no luck...
Any other reason you can think of?
User avatar
BaconFries
 
 
Posts: 5316
Joined: Thu Aug 16, 2007 7:32 pm

Re: Hiding page name following site URL

Post by BaconFries »

Yes, the Host company assured me it is supported
Yes, they may support it but is it enabled by them? It needs to be enabled in the web server's main configuration file. I would contact them again and ask them have they enabled it in <Directory></Directory> and it's directives by changing "AllowOverride None" to "AllowOverride All' ( minus the quotes) when done the .htaccess should be working.
Now on this
The host company send me a link to Stackoverflow to search for information
:shock: sorry for the shock but they should know how to set this as it is a web server configuration with them and for them to give you a link to search and find answers yourself is laughable (not at you but them) when it is really for them to help.
User avatar
Rob
 
 
Posts: 175
Joined: Sun Jan 29, 2012 2:54 pm
Location: MN
Contact:

Re: Hiding page name following site URL

Post by Rob »

BaconFries - Request permission to add a question (or rephrase the existing question)

Here is a link I found - https://www.rapidtables.com/web/tools/r ... rator.html. Thoughts on it's accuracy?

​For a permanent 301 redirect solution on a Linux platform with GoDaddy, which is a better solution in your opinion?

​htaccess:

# Permanent URL redirect - generated by www.rapidtables.com
Redirect 301 /about.html http://www.myurl.com/about/

or php:

<?php
// PHP permanent URL redirect - generated by www.rapidtables.com
header("Location: http://www.myurl.com/about/", true, 301);
exit();
?>

​This is for a simple redirect from about.html to about/ without a change in domain name or host. 

The following would be added to the htaccess file to hide the page extensions (from the WB12 program in options):

PHP EXTENTION REMOVAL
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
 
HTML EXTENTION REMOVAL
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

​I assume this is correct? 
The Website Guy - MN
Small Business Web Design
User avatar
BaconFries
 
 
Posts: 5316
Joined: Thu Aug 16, 2007 7:32 pm

Re: Hiding page name following site URL

Post by BaconFries »

Hi Rob no permissions needed 😀 at all fire away. Both are just as good as each other and they do the same in the end. The PHP does requires the page extension to be .php were you can just add the .htaccess to the original file (if you already have one) and that's it.
The following would be added to the htaccess file to hide the page extensions (from the WB12 program in options):
Yes, you can also add further to it like the redirect, block allow IP address, Prevent Directory Listing, Block bots rven password it etc. With this said your host should support Apache and at the same time it needs to be enabled for it to work.
User avatar
Rob
 
 
Posts: 175
Joined: Sun Jan 29, 2012 2:54 pm
Location: MN
Contact:

Re: Hiding page name following site URL

Post by Rob »

Ok. I was also given this code to put in the htaccess file:

RewriteEngine On
RewriteBase /
RewriteRule ^/about/ /about.html
Redirect 301 /about.html /about/

Seems everyone (each "generator") has a different way to accomplishing this. Thoughts on the best way?

Also, if I am using redirects from nonwww to www as well as index.html to main url, is there a particular order all of this needs to be in?

I'll have to add in redirect from http to https another time...

In the end, I am simply wanting to learn how to 1 - hide page extensions (for security purposes right?) and 2 - ensure that if someone clicks on about.html in the search results they are successfully directing to the right page for about/. Wasn't there a big debate here on how best to accomplish this?

Thank you for the info. I'll have to call the host to ask if apache is supported and if "hide page extensions" is supported on my hosting plan.
The Website Guy - MN
Small Business Web Design
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: Hiding page name following site URL

Post by alex4orly »

Baconfries,

Following your comments above, I contacted again my host company and they pointed me to conduct the tests listed in the following link:
https://docs.bolt.cm/3.4/howto/making-s ... is-working
I conducted the test, all seems fine so they concluded that the problem must be in my .htaccess script itself - which is outside the scope of their support.
Please remember - I am NOT looking for a redirect - just to have the original website showing in the search bar, without the actual pages...
Interestingly, this is exactly how it looks on my Samsung Galaxy phone (Android)... How do they do it?

Cheers
Alex
User avatar
BaconFries
 
 
Posts: 5316
Joined: Thu Aug 16, 2007 7:32 pm

Re: Hiding page name following site URL

Post by BaconFries »

Hi Alex, I know that you are not looking for a redirect that answer was to Rob and not yourself.
Now in some instances you may need to use add "multiviews" to the .htaccess if this is the case then add the following to the top of the .htaccess

Code: Select all

Options +MultiViews


Example:

Code: Select all

<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine on 
RewriteBase / 
RewriteRule ^(.+)\.html$ /$1 [R,L] 
RewriteCond %{REQUEST_FILENAME}.html -f 
RewriteRule ^(.*?)/?$ /$1.html [NC,END]
</IfModule>


And for the removal of the page name and extension try.

Code: Select all

<IfModule mod_rewrite.c>
Options -Multiviews
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*) index.php?$1 [L]
</IfModule>
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: Hiding page name following site URL

Post by alex4orly »

Thaks man,
Not clear - do I need the TWO script segments to be in the .htaccess file ?

<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine on
RewriteBase /
RewriteRule ^(.+)\.html$ /$1 [R,L]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*?)/?$ /$1.html [NC,END]
</IfModule>

AND

<IfModule mod_rewrite.c>
Options -Multiviews
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*) index.php?$1 [L]
</IfModule>
User avatar
BaconFries
 
 
Posts: 5316
Joined: Thu Aug 16, 2007 7:32 pm

Re: Hiding page name following site URL

Post by BaconFries »

No, please simply try each one to see what suits your needs and whatever works use. I don't know who you use for hosting but to be saying to you the customer "it is outside the scope of their support" I would be asking what do you support then as it is s server configuration and do you support this or not!. Right I am going to try and beat the a** out of Mr Insomnia to hopefully get some sleep.
User avatar
alex4orly
 
 
Posts: 632
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: Hiding page name following site URL

Post by alex4orly »

Dear friend, I much appreciate your continous help

I tried the first segment and got the following error. The 2nd segment, I didn't try becasue it only refers to PHP

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@beleuramyhome.org.au and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Post Reply