Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 04:06:36 AM

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 7739 Members
Latest Member: audillino
* Home Help Search Login Register
Pages: [1] 2   Go Down
Print
Author Topic: removing the /pages/ from the address  (Read 2545 times)
kevyn

Offline Offline

Posts: 10


« on: February 16, 2010, 11:08:59 AM »

Hi there,

I tried searching around for the answer to my question but couldn't find anything.

Is it possible to have new pages created without the \pages\ folder being used?

I want:

www.mywebsite.com/page1

I don't want:

www.mywebsite.com/pages/pages1.html

thanks in advance smiley
Logged
WebBird
Guest
« Reply #1 on: February 16, 2010, 11:27:18 AM »

http://www.websitebaker2.org/forum/index.php/topic,15507.0.html
Logged
kevyn

Offline Offline

Posts: 10


« Reply #2 on: February 16, 2010, 11:41:11 AM »

Thanks for that link, however I couldn't seem to make it work using those instructions - they don't appear to be tested anyway

I guess I'll have to wait for someone clever to make a plugin for it!
Logged
WebBird
Guest
« Reply #3 on: February 16, 2010, 12:53:12 PM »

If you have an Apache webserver, just use MOD_REWRITE.

Edit: This works for me (Windows XP, Apache 2.2)

Code:
RewriteEngine on
RewriteBase /_projects/wb28
RewriteRule ^([^.]+).html$ pages/$1.php

Replace RewriteBase with the path where the pages directory resides. The RewriteRule replaces all occurences of "anything but dot - dot - html" with "pages/<the part before the .html>.php"

Note: If a non existing page is entered, the "true" path will be shown in the error message. So you may want to add an error handler, too.

See http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

When clicking on a page link inside WB, the /pages/ directory will occur in the link, anyway.
« Last Edit: February 16, 2010, 01:28:20 PM by WebBird » Logged
kevyn

Offline Offline

Posts: 10


« Reply #4 on: February 16, 2010, 01:11:13 PM »

Thanks but I'm a php noob. I have used this from your previous link:

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;
        }
    }


Which has made my links appear on the site as www.domain.com/test -however when you press on the link it cannot find the page.

I also added this to HTaccess:

Code:
# Example .htaccess wich allows to parse .html as php
AddType application/x-httpd-php .html

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


however my problem still remains
Logged
WebBird
Guest
« Reply #5 on: February 16, 2010, 01:26:10 PM »

With the above example (add to .htaccess in your WB directory) you won't have to change any php files.
Logged
crnogorac081
AddOn Development
*
Offline Offline

Posts: 1706



« Reply #6 on: February 16, 2010, 02:05:06 PM »

does it work for all sub pages , for example: www.mzsite.xz/pages/sub/sublevel/sub_sub_level/this_page.php ?
Logged

Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
kevyn

Offline Offline

Posts: 10


« Reply #7 on: February 16, 2010, 02:05:51 PM »

Well above is my htaccess file, and I have gone back to using the original php files - but I still have the long ugly URLs sad
Logged
WebBird
Guest
« Reply #8 on: February 16, 2010, 02:16:33 PM »

@crnogorac081: No, you will have to change the RewriteRule for this case.

@kevyn: When clicking on page links you have. Like I said. grin
Logged
Monky
Development Team
*****
Offline Offline

Posts: 47



WWW
« Reply #9 on: February 16, 2010, 02:22:21 PM »

With the above example (add to .htaccess in your WB directory) you won't have to change any php files.
When you want the internal links inside your WB to be short too, you will have to change WB core files.

And I think he does not want .html extension either.
Logged
WebBird
Guest
« Reply #10 on: February 16, 2010, 02:24:02 PM »

Aaah... you want to store the files at "WB installation root"? (Bad idea...) To do this, set the "pages directory" (Backend, Advanced settings) from "/pages" to "/". Be sure that you have NO pages before doing this!

After this change, all access files will be stored directly in the WB root dir. (But you really shouldn't do that...)
Logged
WebBird
Guest
« Reply #11 on: February 16, 2010, 02:26:07 PM »

And I think he does not want .html extension either.

Would be better to use an extension, otherwise he will have to exclude all the WB subdirs (like "admin", "templates", "modules" etc.) from the MOD_REWRITE.
Logged
Monky
Development Team
*****
Offline Offline

Posts: 47



WWW
« Reply #12 on: February 16, 2010, 02:59:21 PM »

Aaah... you want to store the files at "WB installation root"? (Bad idea...)
I think it's OK for him to keep the /pages folder as long as it doesn't show up in the URLs.
But I'll quit the oracle job now =)
Logged
crnogorac081
AddOn Development
*
Offline Offline

Posts: 1706



« Reply #13 on: February 16, 2010, 03:21:33 PM »

I stored my pages i root, and set root folder to 755.. I know it is not good, but since root has 755 I didnt have problems so far Smiley

But it would be nice to create some kind of .htaccess plugin (like a module which will upload .htaccess file to root and set up things Smiley )

Unfortunatelly, I had no experience and knowledge about .htaccess..  cry
Logged

Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
kevyn

Offline Offline

Posts: 10


« Reply #14 on: February 16, 2010, 05:54:53 PM »

So would it be safe to simply change the pages directory to root?

also, what happens if I change the page extention to nothing? I assume changing it to .html or .php wouldn't be a problem, but what happens if you blank it out all together? (sorry if that's a silly question)

@WebBird - my htaccess file is the code in my older post, and even with that in place, all the links on my site show up as full URLs, and when you click them, they lead you to the complete URL
Logged
bfuller

Offline Offline

Posts: 16


« Reply #15 on: February 16, 2010, 06:19:35 PM »

Kevyn

I think you might get some help from the following link.

http://zenverse.net/seo-friendly-urls-with-htaccess/

Hope it helps.

Bob
Logged
WebBird
Guest
« Reply #16 on: February 16, 2010, 06:53:32 PM »

So would it be safe to simply change the pages directory to root?

No, as you will have to change the access rights to your WB root so that WB can write the files. (See above.) This is why it's a bad idea. Wink

also, what happens if I change the page extention to nothing?

The Web server will no longer execute the files as PHP, but show them as plain text. This is not what you're after. Wink

@WebBird - my htaccess file is the code in my older post, and even with that in place, all the links on my site show up as full URLs, and when you click them, they lead you to the complete URL

The .htaccess means that you can put something like

http://.../bla.html

into your browser address line and get the page

http://.../pages/bla.php

in return. So you can use short URLs in Mails etc. But WB itself will still use the "correct" (long) URLs in the nav menus etc. To change that, you will have to edit the Frontend class as you did above.

In any case, this is a very dirty hack (you will loose when upgrading WB to a newer version), so you may think about it again. Wink What's so bad with /pages/?
Logged
crnogorac081
AddOn Development
*
Offline Offline

Posts: 1706



« Reply #17 on: February 17, 2010, 12:10:19 AM »

But it is safe to set pages in root, if you set 755 to root and all subfolders and files, right ?
Logged

Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
WebBird
Guest
« Reply #18 on: February 17, 2010, 02:17:01 PM »

Define "safe".  grin
Logged
chio
WebsiteBaker Org e.V.

Offline Offline

Posts: 2264


« Reply #19 on: February 17, 2010, 04:45:21 PM »

If you save pages in the root, you will get troubles if you have pages like "modules" or "admin" with subpages. This might destroy your WebsiteBaker installation.

The easiest way is to use mod_rewrite AND of course you have to change all links on your websites:
in index.php after
Code:
$output = ob_get_contents();
ob_end_clean();
add
Code:
$output = str_replace(WB_URL.'/pages/',WB_URL.'/',$output);
(untested)

Logged

*weg*
WebBird
Guest
« Reply #20 on: February 17, 2010, 04:50:57 PM »

This is why I said that you would have to exlude this directory names from the list, using RewriteCond rules.
Logged
sky writer

Offline Offline

Posts: 285



« Reply #21 on: February 20, 2010, 10:04:35 PM »

This thread has me worried.  I have about eight WB sites, and I have removed the /pages and just use root for all of my pages.  I have never run into any trouble.

Can someone explain the dangers, or possible issues?  And when you say, define "safe", exactly what do you mean?
Logged
Waldschwein
Guest
« Reply #22 on: February 20, 2010, 10:35:11 PM »

This thread has me worried.  I have about eight WB sites, and I have removed the /pages and just use root for all of my pages.  I have never run into any trouble.

Can someone explain the dangers, or possible issues?  And when you say, define "safe", exactly what do you mean?

Hello!

Well, the WebsiteBaker site uses no /pages.  grin *cough* Unsafe site... *cough*
No, some modules have problems with no /pages, e.g. you have to change something in the topics module, or you can get problems with the /posts of the normal News form.

But in fact, there are no real problems with not using /pages. Security issues - not really, besides you call a page with subpages on the root level templates, include, framework or media.  wink

Yours Michael
Logged
Luisehahne
Board Member
Development Team
*****
Offline Offline

Posts: 3147



WWW
« Reply #23 on: February 20, 2010, 10:55:42 PM »

May be this is what you searching for?

http://www.websitebakers.com/pages/admin/admin-tools/shortlink.php

Dietmar
Logged

We are human beings - and nobody is perfect at all.
sky writer

Offline Offline

Posts: 285



« Reply #24 on: February 21, 2010, 01:45:33 AM »

Well, the WebsiteBaker site uses no /pages.  grin *cough* Unsafe site... *cough*
No, some modules have problems with no /pages, e.g. you have to change something in the topics module, or you can get problems with the /posts of the normal News form.

But in fact, there are no real problems with not using /pages. Security issues - not really, besides you call a page with subpages on the root level templates, include, framework or media.  wink

Yours Michael


Thanks for the reply.  Sorry, but I think something is getting lost in translation.  Are you saying it is safe, or not safe.  I don't understand from your examples, whether you are saying it is a bad thing, or nothing to worry about.
Logged
Pages: [1] 2   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!