pretty urls problem / redirection to subdirectory

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Locked
spundfix
New Member
New Member
Posts: 6
Joined: Sat May 09, 2015 4:53 pm

pretty urls problem / redirection to subdirectory

Post by spundfix »

hi there,
i have already read a lot of forum entries about this topic but they all could not help my with my problem.
the thing is my installation of cms made simple is in a subdirectory www.website.xy/cmsmadesimple/. until now, i placed a index.html file in my root folder with a redirect. since this is not a nice solution, i wanted to change this workaround by redirecting with htaccess to the subdirectory by following the instructions on changing the config.php and putting a htaccess file in the root respectively the subdirectory. this did not work.

since the path to the website shown in the browser is something like
http://some.servername.net/website/cmsmadesimple, i wonder what is going on here; i don't have access to the directory "some", nor "servername" which seem to contain my actual site.
could this be the reason for the not working redirection and config settings?

another thing: in the config file, there is written
$config['root_url'] = 'http://some.servername.net/website/cmsmadesimple';
and
$config['root_path'] = '/home/httpd/docs/website/cmsmadesimple';
maybe i should change the address of the root url? and if yes, in which way?

thank you in advance for your help!
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: pretty urls problem / redirection to subdirectory

Post by Rolf »

- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
spundfix
New Member
New Member
Posts: 6
Joined: Sat May 09, 2015 4:53 pm

Re: pretty urls problem / redirection to subdirectory

Post by spundfix »

thank you rolf,

the first part of my problem seems to be solved by placing the following code in the htaccess file:

Code: Select all

# redirect to www-directory and hide the /www in the URL
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule !^cmsmadesimple(/?|/.+)$ /cmsmadesimple%{REQUEST_URI} [L]
the index.php in the subdirectory is displayed and in the browser the url shows a pretty website.xy .

but still, when i want to click through the pages of the website,a 404 error is returned - the requested URL /website/cmsmadesimple/pagename is not found on this server (the browser shows the following url: http://some.servername.net/website/cmsm ... e/pagename)
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: pretty urls problem / redirection to subdirectory

Post by Dr.CSS »

If you are using a subfolder for the site and want pretty URLs, even if it is a subdomain.domain.com set up, you need to use the rewritebase thingy in your htaccess...

RewriteBase /THE NAME OF THE SUBFOLDER
spundfix
New Member
New Member
Posts: 6
Joined: Sat May 09, 2015 4:53 pm

Re: pretty urls problem / redirection to subdirectory

Post by spundfix »

Thanks Dr. CSS,
i already set the .htacces the way you described:

Code: Select all

RewriteBase /cmsmadesimple
but this did not work the way i supposed it should.

or did you mean like this:

Code: Select all

RewriteBase /some.servername.net/website/cmsmadesimple
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: pretty urls problem / redirection to subdirectory

Post by Jo Morg »

most likely:

Code: Select all

RewriteBase /website/cmsmadesimple
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
spundfix
New Member
New Member
Posts: 6
Joined: Sat May 09, 2015 4:53 pm

Re: pretty urls problem / redirection to subdirectory

Post by spundfix »

jo morg,
thank you for your advice, but changing the rewritebase that way does not change the website behaviour.
i still get 404 and
The requested URL /website/cmsmadesimple/post_slug was not found on this server.
the url shown in the browser is http://some.servername.net/website/cmsm ... /post_slug
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: pretty urls problem / redirection to subdirectory

Post by Rolf »

I have my website in a subfolder named www which contains my CMSMS website.
In the root folder I have a .htaccess file containing:

Code: Select all

#
RewriteEngine On
RewriteBase /www

# redirect to www-directory and hide the /www in the URL
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule !^www(/?|/.+)$ /www%{REQUEST_URI} [L]
In the subfolder I use the regular (unchanged) CMSMS .htaccess file.
In the config.php file I have the settings for a regular setup with pretty urls

Code: Select all

$config['root_url'] = 'http://www.website.com';
$config['url_rewriting'] = 'mod_rewrite';
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: pretty urls problem / redirection to subdirectory

Post by Jo Morg »

@spundfix: As usual this is a typical case of lack if information from your part. All the solutions given on this topic work and have been tested, but we are only trying to guess what it is that you want to do. Please take the time to read this and elaborate on what it is that you expect to accomplish. Your 1st post is confusing at best imNSHo. There is no "one solution fits all"...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: pretty urls problem / redirection to subdirectory

Post by Dr.CSS »

It sounds like you have a subdomain, which is a subfolder, with a subfolder inside a subfolder which has CMSMS installed in it...

IMHO you're not going to get pretty URLs working...

Would you mind telling me why you have it buried so deep in your server..?
spundfix
New Member
New Member
Posts: 6
Joined: Sat May 09, 2015 4:53 pm

Re: pretty urls problem / redirection to subdirectory

Post by spundfix »

dear Dr. CSS,
good question - i will have to ask my provider why he has buried my domain deeply, deeply down in his server dungeons. :-)

dear Jo Morg,
you are right - i did not list my system informations. here they are:
CMS Made Simple 1.12, PHP 5.4.25, MySQL 5.0.37,
working with apache/2.0.59easytecc/2.0 (unix) dav/2 php/5.4.25 mod_perl/2.0.3 perl/v5.8.5,
running on linux 2.6.16duke12-host an i686.

but i doubt this information is the key to solving my problem. i rather think it is the strange server system which placed my domain in a subfolder of a subfolder or so.

whatever the reason is, i appreciate every effort to help. thank you already!
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: pretty urls problem / redirection to subdirectory

Post by Jo Morg »

Jo Morg wrote: Please take the time to read this and elaborate on what it is that you expect to accomplish. Your 1st post is confusing at best imNSHo.
spundfix wrote:but i doubt this information is the key to solving my problem. i rather think it is the strange server system which placed my domain in a subfolder of a subfolder or so.
Ok, be it as it may, I'm still not sure of what it is that you are trying to accomplish...
  1. you did not specify if you want to have the url like:
    1. http://some.servername.net/website/cmsmadesimple/pagename.html (or similar);
    2. http://some.servername.net/pagename.html (or similar);
  2. you did not specify if you have different .htaccess files
    on each of the folders and what is the content of each if any;
  3. Only now we know that you have CMSMS 1.12, but was it an upgrade?
    1. if it was the $config['root_path'] is not needed anymore (unless you have the Cataloger module installed which is something you didn't inform us about either: modules list etc, etc...);
    2. also in that case $config['root_url'] may or may not be needed, depending on what you are trying to do... (for instance if you are trying to accomplish the same as RolfTJ, then it is needed...);
  4. is it the main domain or a sub domain? (you mention some.servername.net at some point as you mention http://www.website.xy another...);
The list of things that are pertinent information for us to be able to help is longer...and a quality answer from any of the comunity members wont be possible without, at least, these points clear.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
spundfix
New Member
New Member
Posts: 6
Joined: Sat May 09, 2015 4:53 pm

Re: pretty urls problem / redirection to subdirectory

Post by spundfix »

thank you jo morg for your patient listing of points lacking my problem description.

here are the details that might help you for getting behind my problem:
i want to have the url like: http://website/pagename.html (or similar);
i tried the following .htaccess file in http://some.servername.net/website/ and in http://some.servername.net/website/cmsmadesimple/

Code: Select all

# Attempt to override some php settings, these settings may be helpful on some hosts if your
# default configuration does not meet CMS's minimum requirements, and your host
# has given your account appropriate permissions
#php_value upload_max_filesize "10M"
#php_value session_save_path "tmp/cache"

#php_flag magic_quotes_gpc Off
#php_flag register_globals Off
#php_flag session.use_trans_sid Off

# This is important, so uncomment if your host permit
#Options -Indexes
#ServerSignature Off
#php_value session.cookie_httponly true

#Options +FollowSymLinks

# To prevent E_STRICT problems with PHP 5.3+ you can uncomment the following lines
# Note: These settings should only be enabled for production sites!
#php_flag display_startup_errors 0
#php_flag display_errors 0
#php_flag html_errors 0
#php_value docref_root 0
#php_value docref_ext 0

<IfModule mod_rewrite.c>
RewriteEngine on
#
#Sub-dir e.g: /cmsms
RewriteBase /website/cmsmadesimple

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
# but ignore POST requests.
#RewriteCond %{REQUEST_URI} !/$
#RewriteCond %{REQUEST_URI} !\.
#RewriteCond %{REQUEST_METHOD} !POST$
#RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
</IfModule>

<IfModule mod_headers.c>
# Disable ETags
Header unset ETag
FileEtag None
# For Security
Header set X-Frame-Options "SAMEORIGIN"
</IfModule>

<IfModule mod_deflate.c>
# Compress css, plaintext, xml, gif, and images in transport.
AddOutputFilterByType DEFLATE text/css text/plain text/xml image/gif image/jpeg image/png
</IfModule>

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
# Set expires tags on various file types... so that the browser wont attempt to reload them.
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/ico "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType video/x-flv "access plus 1 year"
ExpiresByType application/pdf "access plus 1 year"
ExpiresByType application/x-shockwave-flash "access plus 1 year"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
<IfModule mod_headers.c>
  # Setting cache control to public allows proxy servers to cache the items too.
  Header set Cache-Control "public"
</IfModule>
</IfModule>


i have upgraded to CMSMS 1.12.

installed modules:
CMSMailer 5.2.2, FileManager 1.4.5, MenuManager 1.8.6, ModuleManager 1.5.8, News 2.15.1, Printing 1.1.2, Search 1.7.12, ThemeManager 1.1.8, TinyMCE 2.9.12, Archiver 0.2.6, CMSPrinting 1.0.5, MicroTiny 1.2.9

main domain or a sub domain?
until recently, i thought my website.xy was the main domain. recently i found out, that obviously this is not the case. my domain website.xy seems to be the subdomain of http://some.servername.net.
that's why i wanted to create a redirect which lets the common user get the impression that website.xy is a main domain, so that for example posting a link from my website to Facebook does not look like http://some.servername.net/website/cmsmadesimple/pagename.html, but http://www.website.xy/pagename.html.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: pretty urls problem / redirection to subdirectory

Post by Jo Morg »

spundfix wrote:main domain or a sub domain?
until recently, i thought my website.xy was the main domain. recently i found out, that obviously this is not the case. my domain website.xy seems to be the subdomain of http://some.servername.net.
This makes no sense at all. DNS has the following structure: the TLD (Top Level Domain) usually com or org or by country etc, the main label (which we usually call the main domain but is the hosting domain) which is what you typically register and under which (depending on the contract you have with your hosting company) you can have from none to an unlimited number of sub-domains. These can go (down the hierarchy and from right to left from the higher level to the lower level) up to 127 levels.(*)

So a domain would be: domain-name.tld...
A sub-domain of the previous domain would be: sub.domain-name.tld...
And you can find: sub3.sub2.sub1.domain-name.tld... etc...

So I'd recommend either moving the site to the root of the domain, or follow RolfTJ's link and implement his solution. But you need to understand what you are doing otherwise it wont work...
(*) http://en.wikipedia.org/wiki/Domain_Name_System
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: pretty urls problem / redirection to subdirectory

Post by Dr.CSS »

If you didn't set this up as a subdomain but just bought hosting it sounds like it's hosted on a subdomain that lets you have websites in subfolders...

Do they have any others hosted like this?

Either ask them how to get just your domain hosted or look for a different host...
Locked

Return to “The Lounge”