Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
May 26, 2012, 12:41:42 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Interested in joining the WebsiteBaker team?
For more Information read
here
or on our
new website
.
155533
Posts in
21713
Topics by
7738
Members
Latest Member:
Pattieardathfe
WebsiteBaker Community Forum
English
Help & Support
(Moderators:
Argos
,
badknight
)
Hide "page" directory and "php" extension
Pages: [
1
]
Go Down
Author
Topic: Hide "page" directory and "php" extension (Read 5048 times)
cosmorphis
Offline
Posts: 3
Hide "page" directory and "php" extension
«
on:
October 06, 2009, 12:15:25 AM »
Just want to say, after I've discovered websitebaker, I've been using it for all my CMS needs. Easy to use, install, maintain, create templates for, etc., and especially easy for my clients!! All the others are so freaking complicated.
Well, what I've been wanting to do for awhile is:
- Remove the "page" directory from the URL
- Remove the ".php" extension from the URL
Instead of my links looking like
http://domain/pages/about-us.php
I would like them to look like
http://domain/about-us
I think it would make it a lot more professional looking. I have been doing some searches, and a lot come up under the German section, and well, I don't speak/read German.
I know it would involve:
- Editing the .htaccess file
- Editing the template (show_menu) to spit out the URLs as modified
I can easily make WebsiteBaker use the root directory to remove the pages directory, but that seems to be ill advised. I know if I take the time to read and learn, I could probably get it going myself--I'm just a little over whelmed trying to stay on top of typography, html, css, photoshop, actionscript, javascript, php, mysql, etc.
If there is a canned solution, or this has been done already, I would really, really appreciate a point in the right direction.
Thanks!
Logged
crnogorac081
AddOn Development
Offline
Posts: 1706
Re: Hide "page" directory and "php" extension
«
Reply #1 on:
October 06, 2009, 08:30:21 AM »
If you remove folder PAGES, and place your pages in root (
www.mysite.xy/page1.php
) you will not be able to add more pages in root, unless you set permissions to 777 when you want to do that..and when you are done you will need to return permissions to 755.. While you have 777, you are vunerable to any hacker atemp.. that is why this is not advised..
Regardint revriteing .php to .html , there is a htaccess.txt in instalation package, which needs to be revrited to .htaccess if you want pages to be .html
cheers
Logged
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
kweitzel
Forum administrator
Offline
Posts: 6975
Re: Hide "page" directory and "php" extension
«
Reply #2 on:
October 06, 2009, 10:50:38 AM »
Quote
If you remove folder PAGES, and place your pages in root (
www.mysite.xy/page1.php
) you will not be able to add more pages in root, unless you set permissions to 777 when you want to do that..and when you are done you will need to return permissions to 755
This is not entirely right, it depends on your server configuration if it works or not! And there is no "out of the box" solution which you can "just" enable.
1) Pages folder: should be removed before adding any pages, otherwise you need to manipulate the whole site structure, access files, database and so on ...
Check out apache mod_rewrite rules to get rid of the pages folder "on the fly" without changing the structure. Haven't tried it myself though
Try this solution:
http://www.websitebaker2.org/forum/index.php/topic,14455.0.html
... but no warranty that it works for you.
cheers
Klaus
Logged
WebsiteBaker Org e.V. - for WebsiteBaker
Luisehahne
Board Member
Development Team
Offline
Posts: 3147
Re: Hide "page" directory and "php" extension
«
Reply #3 on:
October 06, 2009, 11:23:25 AM »
I think you need a change to shortlink. I know, there is something in development.
Dietmar
Logged
We are human beings - and nobody is perfect at all.
Hans>NULL
Offline
Posts: 1389
Re: Hide "page" directory and "php" extension
«
Reply #4 on:
October 06, 2009, 01:06:34 PM »
Hide Extension (.php) unterdrücken/verstecken
Reg.
Logged
/dev/null Ort ohne Wiederkehr
cosmorphis
Offline
Posts: 3
Re: Hide "page" directory and "php" extension
«
Reply #5 on:
October 08, 2009, 05:08:34 AM »
Here is what I have so far. I know it's crude, and might break further down the road, but since nobody has any solution, I figured this would be a good starting point:
For the .htaccess file:
Code:
RewriteEngine on
RewriteRule ^([^.]+)$ pages/$1.php
For the ..\framework\class.wb.php file:
Code:
Changed:
function page_link($link){
// Check for :// in the link (used in URL's) as well as mailto:
if(strstr($link, '://') == '' AND substr($link, 0, 7) != 'mailto:') {
return WB_URL.PAGES_DIRECTORY.$link.PAGE_EXTENSION;
} else {
return $link;
}
}
to
function page_link($link){
// Check for :// in the link (used in URL's) as well as mailto:
if(strstr($link, '://') == '' AND substr($link, 0, 7) != 'mailto:') {
return WB_URL.$link;
} else {
return $link;
}
}
Explanation:
I don't want to really change the structure of the site, just how it appears in the links. What the .htaccess file is doing is monitoring the INCOMING urls, but actually grabbing the correct URL. For instance, the URL
http://www.domain.com/test
is coming in, but Apache is actually grabbing and throwing up
http://www.domain.com/pages/test.php
. So all the original links work, and the new ones as well.
Now, how do we make all the navigation links look nice as well? I went into ..\framework\class.wb.php and changed how the page_link function is utilized. Everytime WebsiteBaker uses the page_link function, it is displayed without the "page" directory and without the ".php" extension.
Now, I don't make any promises that will this work on your site, or for me later on down the road. I was just too excited that I found a potential solution, that I had to post it up!
Logged
crnogorac081
AddOn Development
Offline
Posts: 1706
Re: Hide "page" directory and "php" extension
«
Reply #6 on:
October 08, 2009, 08:43:04 AM »
Hi,
So now links to the files are displayed like it is folder.. Am I right ?
Also, I will test this too.. Caould anyone else test this ?
all best
ivan
Logged
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
cosmorphis
Offline
Posts: 3
Re: Hide "page" directory and "php" extension
«
Reply #7 on:
October 13, 2009, 08:33:37 AM »
So yes, the goal is to display the URLs as folders. Here is my updated .htaccess file, with comments:
Code:
#If 404 Not Found error, go to homepage
ErrorDocument 404 /index.php
RewriteEngine on
#If URL received with trailing slash (e.g. http://domain/test/) then go to correct page (e.g. http://domain/pages/test.php)
RewriteRule ^([^.]+)/$ pages/$1.php
#If URL received WITHOUT trailing slash (e.g. http://domain/test) then go to correct page (e.g. http://domain/pages/test.php)
RewriteRule ^([^.]+)$ pages/$1.php
#When user types in http://domain/admin or http://domain/admin/, it looks for http://domain/pages/admin.php, which doesn't exist, because of the previous rules. This corrects that.
RewriteRule pages/admin.php admin/index.php
If anybody has anything to add, feel free! I know this code is amateur at best, but heck, it's the only thing I've found on the internet!
Logged
Stefek
WebsiteBaker Org e.V.
Offline
Posts: 4884
Re: Hide "page" directory and "php" extension
«
Reply #8 on:
October 13, 2009, 01:42:49 PM »
Hello 'cosmorphis',
I didn't test your code yet.
I wonder what happens to pages like
account/login.php, account/forgot.php
and also what happens to the SEARCH if it is in use.
Kind Regards,
Stefek
Logged
"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
crnogorac081
AddOn Development
Offline
Posts: 1706
Re: Hide "page" directory and "php" extension
«
Reply #9 on:
October 15, 2009, 12:46:06 AM »
So with this .htaccess rewriteing, there is no need to rewrite framework file ..\framework\class.wb.php ??
cheers
Logged
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
Argos
Moderator
Offline
Posts: 2161
Re: Hide "page" directory and "php" extension
«
Reply #10 on:
October 20, 2009, 11:05:40 AM »
What happens if you have a page called Templates, or Pages, or Media, etc?
Logged
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
WB Showcase:
http://www.mywebsitebaker.com/pages/showcase.php?v&category_id=1242&count=30
----------------------------------------------------------------
Please don't request personal support, use the forums!
LordDarkman
Development Team
Offline
Posts: 343
Re: Hide "page" directory and "php" extension
«
Reply #11 on:
October 21, 2009, 01:24:15 AM »
I tested the solution with win2008Server... funny mess. So I can tell it just works with apache not with IIS.
So I thing there should be an other solution because not everyone is useing apache (most but not all). Maybe Hans>NULL can test it also on his server. I thing it's a gread thing if it works.
CU Moritz
Logged
ChrusR
Offline
Posts: 46
Re: Hide "page" directory and "php" extension
«
Reply #12 on:
August 09, 2010, 04:19:11 PM »
Quote from: cosmorphis on October 06, 2009, 12:15:25 AM
Well, what I've been wanting to do for awhile is:
- Remove the "page" directory from the URL
- Remove the ".php" extension from the URL
I'm really interested to know
if this is on the Roadmap for a future WSB-Version
(out of the box support). I know the
Short Url Hack
(a really nice hack), but it is not supported by all modules and lacks special charaters URLs (like "Füße") and ending slash (dir) support.
I fear that the concept of WSB and its modules is not designed to make this easy available out of the box (I'm not a coder). Many say, that it is not needed for SEO, but I think it would be very useful for replacing existing sites and for nice URLs (quoting in Mails, print, etc.). I know that there is the ReWrite-possibility, but I think it would be better if the WSB-core will support this.
If someone can make a
statement about the WSB-concept on this features (no way, possible, planned, in development)?
Logged
Testing WB since June 2010. HMTL & CSS Knowledge, some JS-Hacking, no real PHP & SQL-Knowledge.
lausianne
WebsiteBaker Org e.V.
Offline
Posts: 155
Re: Hide "page" directory and "php" extension
«
Reply #13 on:
August 12, 2010, 02:32:25 PM »
Hi there,
yes I agree, this would be a very nice feature. Mostly people don't care much, because they understand little and believe the URL must be like that and never ask. But I have a few clients who care and want "pages" removed and have their URLs as short as possible.
Even if it doesn't matter for SEO. When URLs are stored or forwarded or quoted, it does matter - if only aesthetically.
Cheers,
Ralf.
Logged
ChrusR
Offline
Posts: 46
Re: Hide "page" directory and "php" extension - clean short URLs
«
Reply #14 on:
August 15, 2010, 08:20:02 AM »
Quote from: lausianne on August 12, 2010, 02:32:25 PM
But I have a few clients who care and want "pages" removed and have their URLs as short as possible.
Even if it doesn't matter for SEO. When URLs are stored or forwarded or quoted, it does matter - if only aesthetically.
Exactly. And call me paranoid, but I think the URL system can be used by malicous crawlers (f.e. in the case of serious bugs) to recognize the CMS. In every other point WSB is very flexible; AFAIK (as non-coder) the "ghost-php-files writing of the sitemap" in the pages folder is the base concept, that makes it difficult to code a compatible solution (I guess I understand that from some answers in the forum). Maybe this concept has to be reviewed; for me it would be very interesting to understand,
what are the main advantages of the actual WSB-pages concept
and naturally what the (near) future can bring. And I hope that the
wish in this Topic would be considered as a main WSB-feature-improvement
.
Logged
Testing WB since June 2010. HMTL & CSS Knowledge, some JS-Hacking, no real PHP & SQL-Knowledge.
Paul - Westhouse IT
Offline
Posts: 63
Re: Hide "page" directory and "php" extension
«
Reply #15 on:
September 29, 2010, 08:48:49 PM »
I'm not as interested in removing the extension, but I've definitely wanted the pages directory removed from URLs. After quite some work I've put something together that works for me and should for others too:
http://westhouseit.co.uk/topics/websitebaker-remove-pages-from-url.php
Let me know what you think and I'll make any changes needed to get it working properly. I'm also going to get in touch with the WB dev team to see about putting some of this into the core code.
«
Last Edit: September 29, 2010, 08:59:40 PM by Paul - Westhouse IT
»
Logged
Westhouse IT - Professional WebsiteBaker developers for hire.
Ruud
WebsiteBaker Org e.V.
Offline
Posts: 2296
Re: Hide "page" directory and "php" extension
«
Reply #16 on:
September 29, 2010, 10:31:23 PM »
Just removing the /pages from the (advanced) settings is a solution that will technically work fine for most.
A huge
WARNING
is needed here..
By doing this, you will need to explain your users/webmasters/customers they are not allowed to make certain pages.
Creating a page called "config" or "admin" or "framework" or any other existing directory or filename in the WB package will crash the website instantly.
For me that is the main reason for not doing that. I cannot tell my customers "Here you have this user-friendly website, and here is a list of all things you are not allowed to do"
If you do not like /pages try using /html or /{my-language} or /doc /user and so on..
Logged
Professional WebsiteBaker Solutions
Stefek
WebsiteBaker Org e.V.
Offline
Posts: 4884
Re: Hide "page" directory and "php" extension
«
Reply #17 on:
September 30, 2010, 12:08:25 AM »
Quote from: Ruud on September 29, 2010, 10:31:23 PM
By doing this, you will need to explain your users/webmasters/customers they are not allowed to make certain pages.
...
For me that is the main reason for not doing that. I cannot tell my customers "Here you have this user-friendly website, and here is a list of all things you are not allowed to do"
If you do not like /pages try using /html or /{my-language} or /doc /user and so on..
Hello,
wouldn't it be possible to provide a feature (may be a admin-tool) where you can make some restriction depending on filenames (page filenames).
So once set, there comes a massage "please choose another name, for {{name}} is allready reserved for the system".
It doesn't seem to be too hard to do?
Or a automated function, where the media... Constants and also framework/... etc. will be checked while creating a new site at this level(0) and the pages Constant is empty.
Regards,
Stefek
Logged
"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
Luisehahne
Board Member
Development Team
Offline
Posts: 3147
Re: Hide "page" directory and "php" extension
«
Reply #18 on:
September 30, 2010, 02:07:08 AM »
Quote
wouldn't it be possible to provide a feature
is already in work, handle in core
Dietmar
Logged
We are human beings - and nobody is perfect at all.
Hans Toolbox
Offline
Posts: 910
Re: Hide "page" directory and "php" extension
«
Reply #19 on:
September 30, 2010, 02:55:57 AM »
so isset (so is it
)
«
Last Edit: September 30, 2010, 02:57:41 AM by Hans Toolbox
»
Logged
[Die Beleidigung gegenüber mir wurde durch mich gelöscht, User wurde von mir ausgeschlossen - kweitzel]
Paul - Westhouse IT
Offline
Posts: 63
Re: Hide "page" directory and "php" extension
«
Reply #20 on:
September 30, 2010, 08:22:49 AM »
Quote from: Ruud on September 29, 2010, 10:31:23 PM
Just removing the /pages from the (advanced) settings is a solution that will technically work fine for most.
A huge
WARNING
is needed here..
By doing this, you will need to explain your users/webmasters/customers they are not allowed to make certain pages.
Creating a page called "config" or "admin" or "framework" or any other existing directory or filename in the WB package will crash the website instantly.
Yes, it likely would crash in the case where /pages isn't used at all. My solution keeps content under /pages, but uses rewrites to find content. A problem would occur with pages/directories named the same as existing ones, but it would result in a redirection that mostly loops around to the main index page. So the result would be an unreachable page, but not a site failure.
Logged
Westhouse IT - Professional WebsiteBaker developers for hire.
Pages: [
1
]
Go Up
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Announcements
=> Security Announcements
=> Documentation
=> WebsiteBaker Website Showcase
=> Guest Area & Off-Topic
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.9
===> Announcements
===> Help/Support
=====> Modules / Extensions
===> Suggestions
===> Software bugs
=> Help & Support
=> Modules
=> Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
=> jQuery
=> Templates, Menus & Design
=> WebsiteBaker Language Files
=> WebsiteBaker 2.x discussion
=> WebsiteBaker 3
=> Archive (posts up to 2007)
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> WebsiteBaker 2.9
===> Ankündigungen
===> Hilfe/Support
=====> Module / Extensions
===> Vorschläge
===> Softwarefehler
===> Erfahrungs und Testberichte
=> Hilfe/Support
=> Module & Snippets
=> Templates & Design
=> Tutorials
=> jQuery
=> Diskussion über WB
=> Off-Topic
=> Archiv für Themen bis 2007
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Hulp & Ondersteuning
=> Niet-Terzake (Off Topic)
-----------------------------
Francais (French)
-----------------------------
=> Help/Support
-----------------------------
Italiano (Italian)
-----------------------------
=> Help/Support
-----------------------------
Bakery (WB shop module)
-----------------------------
=> Bakery English
=> Bakery Deutsch
-----------------------------
KeepInTouch (Multi Contact Module)
-----------------------------
=> KeepInTouch English
=> KeepInTouch Deutsch
Loading...