[SOLVED] Pretty url in v.1.10.3

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
surogat
Forum Members
Forum Members
Posts: 52
Joined: Sun Jan 27, 2008 6:14 pm

[SOLVED] Pretty url in v.1.10.3

Post by surogat »

I can't get pretty url's on my site.
I have impression that I've tried every possible combination
of following two files associated with CMSMS and the best result was
nicely rewritten url with 404 page..
Since my brain is now quite "boiled", I would be greatful if someone can take a look please and i hope see something that am missing..

Additional lines in config.php are;

Code: Select all

$config['url_rewriting'] = 'mod_rewrite';
$config['page_extension'] = '/';
$config['use_hierarchy'] = true;
$config['query_var'] = 'page';
and .htaccess file in a site root looks like this;

Code: Select all

Options +FollowSymLinks
  RewriteEngine on
  RewriteBase /
 
  # 301 Redirect all requests that don't contain a dot or trailing slash to
  # include a trailing slash
  # except for form POSTS
  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]

Thanks

CMSMS 1.10.3
Banners 2.5.2
CGBlog 1.8.2
CGExtensions 1.27.7
CGSimpleSmarty 1.4.10
CMSMailer 2.0.2
CMSPrinting 1.0
FileManager 1.2.0
JQueryTools 1.0.10
MenuManager 1.7.7
MicroTiny 1.1.1
ModuleManager 1.5.3
NMS 2.3.8
News 2.12.3
Search 1.7
Showtime 2.0.5
Statistics 1.1.3
ThemeManager 1.1.4
TinyMCE 2.9.5
jQuery 1.2.0
Last edited by surogat on Wed Feb 15, 2012 2:58 pm, edited 1 time in total.
bloqhead
New Member
New Member
Posts: 3
Joined: Thu Dec 22, 2011 7:52 pm

Re: Pretty url in v.1.10.3

Post by bloqhead »

Hi, surogat. I'm having the same exact issue as you with the same version of CMSMS. One thing I noticed is that you have a different line than I do in my config:

You have:

Code: Select all

$config['url_rewriting'] = 'mod_rewrite';
and I read elsewhere to use this:

Code: Select all

$config['assume_mod_rewrite'] = true;
I'm not sure which one is correct but neither of them seem to be working anyway :-\
User avatar
manuel
Power Poster
Power Poster
Posts: 354
Joined: Fri Nov 30, 2007 9:15 am

Re: Pretty url in v.1.10.3

Post by manuel »

adding

Code: Select all

$config['url_rewriting'] = 'mod_rewrite';
and uncommenting the lines in .htaccess should suffice to get pretty URL's working...

Have you checked your error logs?
If you installed in a subdir, you need to change the "RewriteBase /" accordingly (with a trailing slash)

Greetings,
Manuel
surogat
Forum Members
Forum Members
Posts: 52
Joined: Sun Jan 27, 2008 6:14 pm

Re: Pretty url in v.1.10.3

Post by surogat »

@bloqhead it's kind of comforting not to be alone in this darkness :)
@manuel
Well .htaccess, and config.php are just like I wrote, i don't know what's left to uncomment.
But it may be the problem in my server (IIS7.5)..
I've also put web.config from the handbook, but still nothing..

web.config ;

Code: Select all

 <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <configSections>
            <sectionGroup name="system.webServer">
                <sectionGroup name="rewrite">
                    <section name="rewriteMaps" overrideModeDefault="Allow" />
                    <section name="rules" overrideModeDefault="Allow" />
                </sectionGroup>
            </sectionGroup>
        </configSections>
    
        <system.webServer>
            <security>
                <!--  This section should be uncommented after
                installation to secure the installation. -->
                <!--
                <requestFiltering>
                    <denyUrlSequences>
                        <add sequence="engine" />
                        <add sequence="inc" />
                        <add sequence="info" />
                        <add sequence="module" />
                        <add sequence="profile" />
                        <add sequence="po" />
                        <add sequence="sh" />
                        <add sequence="theme" />
                        <add sequence="tpl(\.php" />
                        <add sequence="Root" />
                        <add sequence="Tag" />
                        <add sequence="Template" />
                        <add sequence="Repository" />
                        <add sequence="code-style" />
                    </denyUrlSequences>
                    <fileExtensions>
                        <add fileExtension=".sql" allowed="false" />
                        <add fileExtension=".pl" allowed="false" />
                    </fileExtensions>
                </requestFiltering>
                -->
            </security>
            <directoryBrowse enabled="true" />
        <caching>
                <profiles>
                    <add extension=".php" policy="DisableCache" kernelCachePolicy="DisableCache" />
                    <add extension=".html" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="14:00:00:00" />
                </profiles>
            </caching> 
            <rewrite>
                <rules>
                    <rule name="block favicon" stopProcessing="true">
                        <match url="favicon\.ico" />
                        <action type="CustomResponse" statusCode="404" subStatusCode="1" 
                            statusReason="The requested file favicon.ico was not found" 
                            statusDescription="The requested file favicon.ico was not found" />
                    </rule>
                    <rule name="Imported Rule 2" stopProcessing="true">
                        <match url="^(.*)$" ignoreCase="false" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="true" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="true" negate="true" />
                <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php?page={R:1}" appendQueryString="true" />
                    </rule>
                </rules>
            </rewrite>
            <defaultDocument>
                <files>
                    <remove value="index.php" />
                    <add value="index.php" />
                </files>
            </defaultDocument>
    
            <!-- HTTP Errors section should only be enabled if the "Error Pages"
            feature has been delegated as "Read/Write" at the Web Server level.        -->
               <httpErrors>
                   <remove statusCode="404" subStatusCode="-1" />
                   <error statusCode="404" prefixLanguageFilePath="" path="/index.php" responseMode="ExecuteURL" />
               </httpErrors>
    
    
        </system.webServer>
    </configuration> 
i guess am not smart enough :-\ tnx
User avatar
frankmanl
Power Poster
Power Poster
Posts: 425
Joined: Sat Jul 12, 2008 3:50 am

Re: Pretty url in v.1.10.3

Post by frankmanl »

I'm no expert in .htaccess, but recently I learned that the [L] flag means: last line to read an execute. Which means after

Code: Select all

RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
nothing will be processed.
So move the L to the last line you want to have executed.

See http://httpd.apache.org/docs/2.2/rewrite/flags.html for reference.

Frank
surogat
Forum Members
Forum Members
Posts: 52
Joined: Sun Jan 27, 2008 6:14 pm

Re: Pretty url in v.1.10.3

Post by surogat »

@frank

Code: Select all

RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
is from here
http://wiki.cmsmadesimple.org/index.php ... And_Tricks
and here;
http://wiki.cmsmadesimple.org/index.php ... l_Settings
If it's not outdated..
User avatar
frankmanl
Power Poster
Power Poster
Posts: 425
Joined: Sat Jul 12, 2008 3:50 am

Re: Pretty url in v.1.10.3

Post by frankmanl »

Yes, but did you try it?
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Pretty url in v.1.10.3

Post by Dr.CSS »

Windows servers most times don't allow pretty URLs unless you know some trick others don't know about...
surogat
Forum Members
Forum Members
Posts: 52
Joined: Sun Jan 27, 2008 6:14 pm

[SOLVED] Pretty url in v.1.10.3

Post by surogat »

The trick is to have these 3 things in your root directory;

1. additional lines in config.php

Code: Select all

$config['url_rewriting'] = 'mod_rewrite'; 
$config['page_extension'] = '/';
$config['use_hierarchy'] = false;
$config['query_var'] = 'page';
2. .htaccess file (the one from /doc folder, renamed htaccess.txt)

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

#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 /

# 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_header.c>
# Disable ETags
Header unset ETag
FileEtag None
</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>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
# Set expires tags on various files... so that the browser wont attempt to reload them.
ExpiresActive On
ExpiresDefault "access plus 1 year"
<IfModule mod_header.c>
  # Setting cache control to public allowes proxy servers to cache the items too.
  Header set Cache-Control "public"
</IfModule>
</FilesMatch>
</IfModule>
and 3. web.config file (needed for IIS (7.5 in may case) interpretation of .htaccess)

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <configSections>
            <sectionGroup name="system.webServer">
                <sectionGroup name="rewrite">
                    <section name="rewriteMaps" overrideModeDefault="Allow" />
                    <section name="rules" overrideModeDefault="Allow" />
                </sectionGroup>
            </sectionGroup>
        </configSections>
   
        <system.webServer>
            <security>
                <!--  This section should be uncommented after
                installation to secure the installation. -->
                <!--
                <requestFiltering>
                    <denyUrlSequences>
                        <add sequence="engine" />
                        <add sequence="inc" />
                        <add sequence="info" />
                        <add sequence="module" />
                        <add sequence="profile" />
                        <add sequence="po" />
                        <add sequence="sh" />
                        <add sequence="theme" />
                        <add sequence="tpl(\.php" />
                        <add sequence="Root" />
                        <add sequence="Tag" />
                        <add sequence="Template" />
                        <add sequence="Repository" />
                        <add sequence="code-style" />
                    </denyUrlSequences>
                    <fileExtensions>
                        <add fileExtension=".sql" allowed="false" />
                        <add fileExtension=".pl" allowed="false" />
                    </fileExtensions>
                </requestFiltering>
                -->
            </security>
            <directoryBrowse enabled="true" />
        <caching>
                <profiles>
                    <add extension=".php" policy="DisableCache" kernelCachePolicy="DisableCache" />
                    <add extension=".html" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="14:00:00:00" />
                </profiles>
            </caching>
            <rewrite>
                <rules>
                    <rule name="block favicon" stopProcessing="true">
                        <match url="favicon\.ico" />
                        <action type="CustomResponse" statusCode="404" subStatusCode="1"
                            statusReason="The requested file favicon.ico was not found"
                            statusDescription="The requested file favicon.ico was not found" />
                    </rule>
                    <rule name="Imported Rule 2" stopProcessing="true">
                        <match url="^(.*)$" ignoreCase="false" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="true" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="true" negate="true" />
                <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php?page={R:1}" appendQueryString="true" />
                    </rule>
                </rules>
            </rewrite>
            <defaultDocument>
                <files>
                    <remove value="index.php" />
                    <add value="index.php" />
                </files>
            </defaultDocument>
   
            <!-- HTTP Errors section should only be enabled if the "Error Pages"
            feature has been delegated as "Read/Write" at the Web Server level.        -->
               <httpErrors>
                   <remove statusCode="404" subStatusCode="-1" />
                   <error statusCode="404" prefixLanguageFilePath="" path="/index.php" responseMode="ExecuteURL" />
               </httpErrors>
        </system.webServer>
    </configuration> 
and it works..
Scud
New Member
New Member
Posts: 5
Joined: Thu Feb 16, 2012 12:10 am

Re: [SOLVED] Pretty url in v.1.10.3

Post by Scud »

I have just tried this to no success. The code seems to change the links to the correct urls, however the pages do not load. Says they cannot be found.
cb2004
Power Poster
Power Poster
Posts: 317
Joined: Wed Jul 04, 2007 3:39 pm

Re: [SOLVED] Pretty url in v.1.10.3

Post by cb2004 »

Windows servers should use the internal pretty url method. Read the configuration PDF in the docs folder.
surogat
Forum Members
Forum Members
Posts: 52
Joined: Sun Jan 27, 2008 6:14 pm

Re: [SOLVED] Pretty url in v.1.10.3

Post by surogat »

Scud wrote:I have just tried this to no success. The code seems to change the links to the correct urls, however the pages do not load. Says they cannot be found.
Is your site on IIS server?
And if it is, did you make web.config file?
MLdB
New Member
New Member
Posts: 6
Joined: Fri Feb 10, 2012 5:41 pm

Re: [SOLVED] Pretty url in v.1.10.3

Post by MLdB »

Scud wrote:I have just tried this to no success. The code seems to change the links to the correct urls, however the pages do not load. Says they cannot be found.
I can't seem to get pretty URLs to work like I think they are supposed to. .htaccess seems to work fine, http://www.example.com/a/b/c/ is nicely converted to http://www.example.com/index.php?page=/a/b/c/ (a fact that doesn't show up in the browser address bar of course, but $_GET['page'] == '/a/b/c/').

Also, the routemanager is doing its work properly. If, for example, my module registers a route that reads 'param_a/param_b/param_c/', $_REQUEST['cntnt01param_a'] will be 'a', $_REQUEST['cntnt01param_b'] will be 'b' and so on.

But my module is not receiving these same parameters as $params['param_a'].

What can possibly go wrong?

@Scud: In your case, did $_REQUEST contain the params from the pretty URL? If so and if you solved this, how?
Locked

Return to “[locked] Installation, Setup and Upgrade”