Topic: Installed Wolf into Sub-Directory, would like to remove it from URL

Hi all!

I've installed Wolf into a sub-directory to keep things tidy in the root, but I have two problems:

1) Wolf doesn't automatically rewrite the root (mysite.com) into the sub directory (mysite.com/wolfcms)

2) I would actually like to remove /wolfcms subdirectory out of the url. In other words, instead of visitors seeing:

       "mysite.com/woflcms/index"

   They would instead see:

       "mysite.com/index"

I know this is possible using mod_rewrite, I just don't know how (prior to posting this, I spent hours searching. I just don't understand it all).

Thanks in advanced!!

Thumbs up

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

Try this... Put the the following code into the .htaccess file in your root directory. This code assumes Wolf lives in the wolfcms subdirectory.

Edit: didn't try it out, but think this should be enough

#
# Setting Wolf CMS requirements
#
# On some server configurations you may need to comment out one or more of
# the three lines below due to server limitations.
#

php_flag magic_quotes_gpc off
AddDefaultCharset UTF-8
Options -Indexes +FollowSymLinks

#
# Setting rewrite rules
#

<IfModule mod_rewrite.c>
RewriteEngine On
# Set next line to your Wolf CMS root - if not in subdir, then just /
RewriteBase /

# Rules to allow install sequence to test for mod_rewrite support
RewriteRule ^install/index.html$ wolfcms/install/index.php?rewrite=1 [L,QSA]
RewriteRule ^install/index.php$ wolfcms/install/index.php?rewrite=1 [L,QSA]
RewriteRule ^install/$ wolfcms/install/index.php?rewrite=1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
# Administration URL rewriting.
RewriteRule ^admin(.*)$ wolfcms/admin/index.php?$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
# Main URL rewriting.
RewriteRule ^(.*)$ wolfcms/index.php?WOLFPAGE=$1 [L,QSA]

</IfModule>

Last edited by mvdkleijn (2010-02-19 20:40)

Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution.

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

I appreciate such a quick reply!!

Unfortunately, it didn't work. However, I received a 404 error, instead of the 403 I've been getting, which (I assume) means that we're getting closer!! Also, my domain is anthonygarritano.com (should have posted it earlier). Wolf still shows content at anthonygarritano.com/wolfcms.

Thanks again! If there's any other info I can post that will clarify things, just let me know!!

Thumbs up

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

Sorry! Must've been preoccupied with a feature I'm working on.

Try this for .htaccess:

<IfModule mod_rewrite.c>
  RewriteEngine On
  # Set next line to your Wolf CMS root - if not in subdir, then just /
  RewriteBase /

  # Rules to allow install sequence to test for mod_rewrite support
  RewriteRule ^install/index.html$ wolfcms/install/index.php?rewrite=1 [L,QSA]
  RewriteRule ^install/index.php$ wolfcms/install/index.php?rewrite=1 [L,QSA]
  RewriteRule ^install/$ wolfcms/install/index.php?rewrite=1 [L,QSA]
  
  # Administration URL rewriting.
  RewriteRule ^admin(.*)$ wolfcms/admin/index.php?$1 [L,QSA]
  
  # Main URL rewriting.
  RewriteRule ^(.*)/public/(.*)$ wolfcms/public/$2 [L,QSA]
  RewriteRule ^/public/(.*)$ wolfcms/public/$1 [L,QSA]
  RewriteRule ^public/(.*)$ wolfcms/public/$1 [L,QSA]
  RewriteRule ^(.*)$ wolfcms/index.php?WOLFPAGE=$1 [L,QSA]

</IfModule>

Don't forget to set your URL_PUBLIC to the root of your site (e.g. http://www.example.com) and USE_MOD_REWRITE to true in config.php

Be aware that only files in the public directory will be available directly... all other urls will be directed to Wolf CMS.

This *should* all work, but no guarantees nothing will break. wink

Last edited by mvdkleijn (2010-02-19 23:12)

Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution.

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

Not sure if this is what you want, but try it.
Put this in a .htaccess and upload in your root :

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  
  # Add trailing slash if path does not contain a period or end with a slash
  RewriteCond %{REQUEST_URI} !(\.|/$)
  RewriteRule (.*) http://localhost/$1/ [R=301,L]

  #Rewrites http://localhost/wolfcms to http://localhost/
  RewriteCond %{REQUEST_URI} !^/wolfcms
  RewriteRule ^(.*)$ wolfcms/$1 [L]
</IfModule>

Edit Wolf's config.php to use mod_rewrite and edit this so it points to your root:

define('URL_PUBLIC', 'http://localhost/');

No changes should be needed in the wolfcms (subdir) default .htaccess

Last edited by Fortron (2010-02-20 00:13)

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

Thanks mvdkleijn and Fortron, but neither piece of code worked. Is there something on my server that needs to be changed? I'm using DreamHost, if that makes a difference. I really, really appreciate your help!!

Thanks again!

Thumbs up

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

callmetwan wrote:

Thanks mvdkleijn and Fortron, but neither piece of code worked. Is there something on my server that needs to be changed? I'm using DreamHost, if that makes a difference. I really, really appreciate your help!!

Thanks again!

What does your .htaccess file(s) look like?
What is in your config.php?
Does Dreamhost support mod_rewrite?

Would be helpfull to see them.

I have only tested it on XAMPP.

Last edited by Fortron (2010-02-20 00:10)

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

DreamHost does indeed support mod_rewrite. Below is the code out of my root .htaccess, the /wolfcms .htacess, and the config.php file.


In my root .htaccess I have:

Options -Indexes
Options +ExecCGI

AddHandler fastcgi-script fcg fcgi fpl
AddHandler php5-fastcgi .php

Action php5-fastcgi /cgi-bin/dispatch.fcgi

Redirect 301 /contact/ http://anthonygarritano.wufoo.com/forms/contact-me/

# STRONG HTACCESS PROTECTION
<Files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</Files>


# Setting rewrite rules
#

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
 
  # Add trailing slash if path does not contain a period or end with a slash
  RewriteCond %{REQUEST_URI} !(\.|/$)
  RewriteRule (.*) http://anthonygarritano.com/$1/ [R=301,L]
  #Rewrites http://anthonygarritano.com/wolfcms to http://anthonygarritano.com/
  RewriteCond %{REQUEST_URI} !^/wolfcms
  RewriteRule ^(.*)$ wolfcms/$1 [L]
</IfModule>


In the /wolfcms directory .htaccess I have:

#
# Setting Wolf CMS requirements
#
# On some server configurations you may need to comment out one or more of
# the three lines below due to server limitations.
#

php_flag magic_quotes_gpc off
AddDefaultCharset UTF-8
Options -Indexes +FollowSymLinks

#
# Setting rewrite rules
#

<IfModule mod_rewrite.c>
  RewriteEngine On
  # Set next line to your Wolf CMS root - if not in subdir, then just /
  RewriteBase /wolfcms/

  # Rules to allow install sequence to test for mod_rewrite support
  RewriteRule ^install/index.html$ install/index.php?rewrite=1 [L,QSA]
  RewriteRule ^install/index.php$ install/index.php?rewrite=1 [L,QSA]
  RewriteRule ^install/$ install/index.php?rewrite=1 [L,QSA]
 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  # Administration URL rewriting.
  RewriteRule ^admin(.*)$ admin/index.php?$1 [L,QSA]
 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  # Main URL rewriting.
  RewriteRule ^(.*)$ index.php?WOLFPAGE=$1 [L,QSA]

</IfModule>


In the config.php:

<?php

// Database information:
// for SQLite, use sqlite:/tmp/wolf.db (SQLite 3)
// The path can only be absolute path or :memory:
// For more info look at: www.php.net/pdo



// Should Wolf produce PHP error messages for debugging?
define('DEBUG', false);

// Should Wolf check for updates on Wolf itself and the installed plugins?
define('CHECK_UPDATES', true);

// The number of seconds before the check for a new Wolf version times out in case of problems.
define('CHECK_TIMEOUT', 3);

// The full URL of your Wolf CMS install
define('URL_PUBLIC', 'http://anthonygarritano.com/');

// Use httpS for the backend?
// Before enabling this, please make sure you have a working HTTP+SSL installation.
define('USE_HTTPS', false);

// The directory name of your Wolf CMS administration (you will need to change it manually)
define('ADMIN_DIR', 'admin');

// Change this setting to enable mod_rewrite. Set to "true" to remove the "?" in the URL.
// To enable mod_rewrite, you must also change the name of "_.htaccess" in your
// Wolf CMS root directory to ".htaccess"
define('USE_MOD_REWRITE', true);

// Add a suffix to pages (simluating static pages '.html')
define('URL_SUFFIX', '');

// Set the timezone of your choice.
// Go here for more information on the available timezones:
// http://php.net/timezones
define('DEFAULT_TIMEZONE', 'America/Los_Angeles');

// Use poormans cron solution instead of real one.
// Only use if cron is truly not available, this works better in terms of timing
// if you have a lot of traffic.
define('USE_POORMANSCRON', false);

// Rough interval in seconds at which poormans cron should trigger.
// No traffic == no poormans cron run.
define('POORMANSCRON_INTERVAL', 3600);

Last edited by callmetwan (2010-02-20 06:26)

Thumbs up

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

callmetwan wrote:

DreamHost does indeed support mod_rewrite. Below is the code out of my root .htaccess, the /wolfcms .htacess, and the config.php file.

So where is the content of your .htaccess as located in your wolfcms directory?

Last edited by Fortron (2010-02-20 01:53)

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

Sorry about that. Updated my previous post to include the /wolfcms .htaccess contents.

Thumbs up

11

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

Excuse me for jumping here off topic, however, I couldn't stop myself from saying this.

@callmetwan, you should never post this credentials buddy.

// Database settings:
    define('DB_DSN', 'mysql:dbname=**********;host=************;port=3306');
    define('DB_USER', '**********');
define('DB_PASS', '*************');

Some say it's lame or stupid, but I couldn't dare to offend you. Just a suggestion you know, as a fellow WOLFer to another one.

Regarding your question take a look at this topic: http://www.wolfcms.org/forum/topic204.html

cheers.

Edit by mvdkleijn: Blanked credentials in post

Last edited by admin (2010-02-20 12:00)

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

@axejezzy Thank you SO much. I just pasted it without even thinking. I really appreciate you looking for me!

Now that I'm thinking about it, could I ask you to edit my username/password from your post? Thanks again!!

Last edited by callmetwan (2010-02-20 06:36)

Thumbs up

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

Keep the code in the root .htaccess clean for the sake of testing,
even the "Add trailing slash" can be removed.
If you have a index file in the root then remove it.
Change RewriteBase /wolfcms/ to RewriteBase / in your wolfcms directory .htaccess.
The following I have succesfully running on a Linux host:

// root .htaccess

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  
  #Rewrites http://localhost/wolfcms to http://localhost/
  RewriteCond %{REQUEST_URI} !^/wolfcms
  RewriteRule ^(.*)$ wolfcms/$1 [L]
</IfModule>

// wolfcms .htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    # Administration URL rewriting.
    RewriteRule ^admin(.*)$ admin/index.php?$1 [L,QSA]
        
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-d
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-l
    # Main URL rewriting.
    RewriteRule ^(.*)$ index.php?WOLFPAGE=$1 [L,QSA]
</IfModule>

I've also moved the public directory to the root:

// public .htaccess

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
</IfModule>

Hope this works for you.

Last edited by Fortron (2010-05-23 11:15)

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

@Fortron Okay, we're getting somewhere now! I replaced all of the code in the root .htaccess with what you gave me. The following is what I deleted (same as I listed in previous post):

Options -Indexes
Options +ExecCGI
AddHandler fastcgi-script fcg fcgi fpl 
AddHandler php5-fastcgi .php
Action php5-fastcgi /cgi-bin/dispatch.fcgi
Redirect 301 /contact/ http://anthonygarritano.wufoo.com/forms/contact-me/
# STRONG HTACCESS PROTECTION
<Files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</Files>

# Setting rewrite rules
#
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  
  # Add trailing slash if path does not contain a period or end with a slash
  RewriteCond %{REQUEST_URI} !(\.|/$)
  RewriteRule (.*) http://anthonygarritano.com/$1/ [R=301,L]
  #Rewrites http://anthonygarritano.com/wolfcms to http://anthonygarritano.com/
  RewriteCond %{REQUEST_URI} !^/wolfcms
  RewriteRule ^(.*)$ wolfcms/$1 [L]
</IfModule>

Moving the public dir to the root produced pages that were not styled:
http://drp.ly/rGS8X

Moving it back in gives me what you see now:
http://anthonygarritano.com/

All I need to do now is get rid of /wolfcms from the url!!

Thanks again!!

Thumbs up

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

I see your links still contain "wolfcms" in them.
Check your config.php and make sure its not reffering to the wolfcms directory:

define('URL_PUBLIC', 'http://www.yourdomain.com/wolfcms/');

becomes:

define('URL_PUBLIC', 'http://www.yourdomain.com/');

If you followed the instructions in my previous post you should
be able to move the public folder to the root and still have styles available.
Do add a empty .htaccess file to your admin directory so its backend is styled to.
Works fine where I have tested it, both on Windows and Linux.

Last edited by Fortron (2010-05-24 08:46)

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

Fortron, I could kiss you!! (okay, not really, that might be a little weird ;]

Changing the config file to point to the root and not to /wolfcms did the trick!

Once again, thank you, thank you, thank you!!!!!

For posterity, here is what was done:

I wanted to install Wolf into a subdirectory so the root would be kept clean. I successfully installed Wolf in the subdirectory /wolfcms, but when I navigated to the domain in a browser, I received a 404 error. If I browsed to mysite.com/wolfcms, the site would display. So my problem was two fold: I needed to tell my server to point the root to Wolf in the /wolfcms. However, once this was achieved every url on my site had /wolfcms in it (such as: mysite.com/wolfcms/articles  mysite.com/wolfcms/about_us). I needed to remove the /wolfcms from the urls of site.

The following is the code in my root .htaccess file, the /wolfcms .htaccess file, and the config.php file. I have verified that this does indeed allow you to install Wolf into a subdirectory, and remove the subdirectory from every url of your site. Please note that your host must allow you to use mod_rewrite, otherwise this will not work.

::root .htaccess

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  
  #Rewrites http://localhost/wolfcms to http://localhost/
  RewriteCond %{REQUEST_URI} !^/wolfcms
  RewriteRule ^(.*)$ wolfcms/$1 [L]
</IfModule>

:: /wolfcms .htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    # Administration URL rewriting.
    RewriteRule ^admin(.*)$ admin/index.php?$1 [L,QSA]
        
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-d
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-l
    # Main URL rewriting.
    RewriteRule ^(.*)$ index.php?WOLFPAGE=$1 [L,QSA]
</IfModule>

:: config.php    (Note that I did not show my mysql database user/pass here. You still need that, but for obvious security reasons, I did not include that here!)

// Should Wolf produce PHP error messages for debugging?
define('DEBUG', false);

// Should Wolf check for updates on Wolf itself and the installed plugins?
define('CHECK_UPDATES', true);

// The number of seconds before the check for a new Wolf version times out in case of problems.
define('CHECK_TIMEOUT', 3);

// The full URL of your Wolf CMS install
define('URL_PUBLIC', '[url]http://anthonygarritano.com/[/url]');

// Use httpS for the backend?
// Before enabling this, please make sure you have a working HTTP+SSL installation.
define('USE_HTTPS', false);

// The directory name of your Wolf CMS administration (you will need to change it manually)
define('ADMIN_DIR', 'admin');

// Change this setting to enable mod_rewrite. Set to "true" to remove the "?" in the URL.
// To enable mod_rewrite, you must also change the name of "_.htaccess" in your
// Wolf CMS root directory to ".htaccess"
define('USE_MOD_REWRITE', true);

// Add a suffix to pages (simluating static pages '.html')
define('URL_SUFFIX', '.html');

// Set the timezone of your choice.
// Go here for more information on the available timezones:
// [url]http://php.net/timezones[/url]
define('DEFAULT_TIMEZONE', 'America/Los_Angeles');

// Use poormans cron solution instead of real one.
// Only use if cron is truly not available, this works better in terms of timing
// if you have a lot of traffic.
define('USE_POORMANSCRON', false);

// Rough interval in seconds at which poormans cron should trigger.
// No traffic == no poormans cron run.
define('POORMANSCRON_INTERVAL', 3600);

Thanks again to mvdkleijn, Fortron, and axejessy for your help. You've saved me a many long night!!

Thumbs up

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

I used this method to redirect the sub-folder to the main site but now the code in the htaaccess changed my permissions of my folders. I have some images uploaded on my server and I use those images on another website but now those images aren't showing up anymore.

Please help... I'm not familiar with this!

Thumbs up

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

antoina304 wrote:

but now the code in the htaaccess changed my permissions of my folders.

That's not possible. If your permissions were changed, someone or something changed them, but not the htaccess code. Did you do something else around the same time perhaps?

Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution.

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

Hi,
my Wolf is installed in the subdir /cms.

I tried to copy the solution, but it don't work.

::htaccess root:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
 
  #Rewrites http://localhost/cms to http://localhost/
  RewriteCond %{REQUEST_URI} !^/cms
  RewriteRule ^(.*)$ cms/$1 [L]
</IfModule>

::htaccess /cms:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
   
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    # Administration URL rewriting.
    RewriteRule ^admin(.*)$ admin/index.php?$1 [L,QSA]
       
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-d
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-l
    # Main URL rewriting.
    RewriteRule ^(.*)$ index.php?WOLFPAGE=$1 [L,QSA]
</IfModule>

::config.php:

// The full URL of your Wolf CMS install
define('URL_PUBLIC', 'http://www.mbc-fuerth.de/');


The result is:
First I get a tree-structure of the homepage, second click produces a new window with an error and the links is:
http://www.mbc-fuerth.de/http://www.mbc-fuerth.de//articles/http://www.mbc-fuerth.de/

Can anybody help me?

Thumbs up

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

URL_PUBLIC seems to point to http://www.mbc-fuerth.de/cms/
Also you can remove this line since its absolete:

    # Administration URL rewriting.
    RewriteRule ^admin(.*)$ admin/index.php?$1 [L,QSA]

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

Nope, no effect. Same result.
I did the same as in the example.
And it seems that the server don't replace the URL.
This is the first time where I work with this stuff, so I'm not experienced at all.

currently I use this command to move the user from landing page to wolf:

<script language="javascript">
window.location.replace("http://www.mbc-fuerth.de/cms/index.php");
</script>

And while testing I rename index.htm so it is not active.

Last edited by helipilot (2012-04-21 19:08)

Thumbs up

Re: Installed Wolf into Sub-Directory, would like to remove it from URL

It probally is configuration specific;
it doesn't work on my local Debian enviroment but it works fine under Windows/XAMPP
also works on the paid hosting

Last edited by Fortron (2012-04-21 19:48)