Solution - how to enable Pretty URLs

Permalink 6 users found helpful
I've tried a million different Apache config combinations none of which worked. But I've finally nailed it! And not a single manual/instruction/howto I saw has EVER mentioned to add that damn 'Options +FollowSymLinks' line to the config!

I'm running Apache2 on openSUSE 11.2 - just to let you know your Apache config files may be in a different place on a different distro.

As root
1. I checked if I had a mod_rewrite module running by
~>a2enmod -l
No it wasn't
2. I've enabled the mod_rewrite module by
~>a2enmod rewrite
3. Restarted Apache
~>/etc/init.d/apache2 restart
4. Checked again, yes, now it was ON
5. On openSUSE I edited /etc/apache2/httpd.conf and added this under the default directory:

<Directory "/srv/www/htdocs/c5">
Options +FollowSymLinks
AllowOverride all
Order deny,allow
Allow from all
RewriteEngine On
</Directory>

6. Then I enabled Pretty URLs in the Concrete5 Dashboard - Sitewide Settings, clicked Save
7. Then I copied the required code for an .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /c5/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

8. Then I went to my C5 server folder /srv/www/htdocs/c5 and created a .htaccess text file and pasted that code into it
9. Restarted Apache server
~>/etc/init.d/apache2 restart
10. Went to my site, refreshed it, clicked all links and now they all worked!

And Joomla and Drupal are also doing Pretty URLs, I just changed the <Directory "/srv/www/htdocs"> to point to the main server root instead of the c5 folder.

If you're on a real host provider and URL rewrite still doesn't work, instead of the above steps you may try just changing these two files:

.htaccess:
# -- concrete5 urls start --
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule .* index.php/$1 [L]
</IfModule>
# -- concrete5 urls end --


concrete/libraries/request.php:
if (!$path) {
            //$path = Request::parsePathFromRequest('ORIG_PATH_INFO');
            $path = Request::parsePathFromRequest('REDIRECT_URL');
         }


Here's more information about mod_rewrite:http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html...

Hope this helps.

PS. I don't understand why Pretty URLs are shown as folders rather than files, e.g. a .../c5/articles/press-room/article1.php is shown as c5/articles/press-room/article1/? But, if it help Google to do its thing, I don't really care.

linuxoid
View Replies:
okhayat replied on at Permalink Reply
okhayat
hehe.. glad you could solve it.

About pretty URLs as folders, the / in between the words really doesn't relate in anyway to folders.
I recently used CodeIgniter and before it Django and it's all the same.
The URLs don't have any thing to do with folders.
DavidMIRV replied on at Permalink Reply
DavidMIRV
Yes actually a recent google webmaster blog post states that googlebot recognizes the difference between a url with an ending slash and one without one. I couple of us have made mods to redirect site.com/url/ to site.com/url and therefor avoid SEO dilution through duplicate content, it's not a very difficult mod to make..
megntuck replied on at Permalink Reply
megntuck
Ah, great! I also had a problem getting Pretty URLs to work until I found this post and added the bit about following sym links to the options of my c5 directory.

Wonder why it hasn't been mentioned anywhere else (documentation) yet?
tahse replied on at Permalink Reply
Thanks for the multiple suggestions!

The section below

"If you're on a real host provider and URL rewrite still doesn't work, instead of the above steps you may try just changing these two files:"

Worked for me!
marginalmedia replied on at Permalink Reply
Thank you so much! You just made this novice Concrete5 user very happy! The combo of .htaccess and request.php changes worked for me too.
silverbenz replied on at Permalink Reply
Brilliant! The .htaccess section, including the request.php info, solved the problem for me too.

My only concern is: will this be overwritten if I [inevitably] do a Concrete5 version upgrade in the future??

Cheers,
Ben.
linuxoid replied on at Permalink Reply
linuxoid
It shouldn't, but in any case you can copy the .htaccess contents from the Panel or just keep a backup copy of the file.
bunjigum replied on at Permalink Reply
I tried it but I still can't get it to work. Figuring it out for about 3 hours now... I think need help already.

I wanted to learn Concrete5 so I set it up in my local machine via virtual hosts.

I unpacked the zip file, paste all in my project root directory. Installation went fine, I included the demo website in my installation. Following the docs, I enabled pretty url. It didn't work, so I followed the solutions in this thread...

I don't have a clue right now... what to do next..

xampp > extra > httpd-vhosts.conf
#CONCRETE5
<VirtualHost *:80>
ServerName concretefive.dev
DocumentRoot "/PATH/TO/SITE/CONCRETEFIVE"
<Directory "/PATH/TO/SITE/CONCRETEFIVE">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


CONCRETEFIVE > .htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule .* index.php/$1 [L]


I tried the trouble shooting from the docs too... changing http.conf, etc. Nothing works.

I hope someone can help me with this. Major Major Roadblock.

P.S typing

http://concretefive.dev/dashboard...
http://concretefive.dev/login

are working fine. My problem is with the links in the demo site.

It's still in http://concretefive.dev/index.php/login/... form when I hover.

I'm desperate... Thank you very much.
silverbenz replied on at Permalink Reply
Forgive me if you've done this already, but you didn't mention it in your post. Did you make the following change to the concrete/libraries/request.php file (as described above):

if (!$path) {
            //$path = Request::parsePathFromRequest('ORIG_PATH_INFO');
            $path = Request::parsePathFromRequest('REDIRECT_URL');
         }


The first time I tried to make this change I forgot to change that file and it didn't work. Once I made the above change it worked beautifully.

Ben.
bunjigum replied on at Permalink Reply
I appreciate your help Ben. I also did that already on CONCRETEFIVE/concrete/libraries/request.php

Here is my updated .htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$1 [L]


and my site.php, if it has something to do with it
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_DATABASE', 'experiment_concretefive');
define('BASE_URL', 'http://concretefive.dev');
define('DIR_REL', '');
define('PASSWORD_SALT', 'MY-PASSWORD-SALT-HERE');
define('PERMISSIONS_MODEL', 'advanced');


I don't understand why when I manually typehttp://concretefive.dev/login it works, but the links still has that index.php. I guess pretty urls is now working but not on rendering the links???

Oh boy.
silverbenz replied on at Permalink Reply
Sorry bunjigum - I'm not a web developer so I'm not really sure where else to suggest looking. I only made the changes suggested in this thread and I don't have any further control over the server (hosted) so I couldn't even say what settings are in place there.

My C5 site is: http://www.oriana.org.au

The pretty-URLs work there.

For what it's worth, my site.php settings are pretty much identical to yours, though I don't use the advanced permissions.

Ben.
bunjigum replied on at Permalink Reply
Hi Ben. I went to http://www.oriana.org.au/dashboard.... So you mean when you hover your links after signing in your admin account, the index.php is not seen on the links e.g http://www.oriana.org.au/index.php/login/logout... ? I just want to clarify the links rendering if pretty-urls are enabled. Does it work both in your local machine and live server or
you developed your site directly on live?

I really appreciate all your help. I'll try concrete5 on my live server when I get home.

I'm at work and all I can think about is how can I get my concrete5 to work... UGH!
silverbenz replied on at Permalink Reply
Hi bunjigum,
When signed in to the page the links you speak of DO still have the /index.php/ section in the URL (eg.http://www.oriana.org.au/index.php/dashboard,... etc). But, when viewing the web site in Edit mode (ie. signed in as admin but just viewing the site as if a normal visitor) the pretty URLs render without the /index.php/.
A normal visitor (ie. someone who doesn't even know this site is editable) sees the pretty URLs.

Hope this helps :)

Ben.

PS. I built the site on my local server _without_ using the pretty URLs functionality; I only added that after I moved the site to the live server.
bunjigum replied on at Permalink Reply
Oh so that was it. Pretty urls will only apply to normal visitor and not the admin..... Ugh all this time I thought it would also change the admin links.... I didn't see this stuff mentioned when I was following the documentation. It should've been included in the docs.

Thanks for the heads up Ben! Also thanks for the time and esp. the patience! Cheers!
linuxoid replied on at Permalink Reply
linuxoid
Sorry to rain on your parade, but PrettyURLs work fine on my site for any user incl. admin. Try asking your host provider to check it out. My hosting is Digital Pacific and they helped my with the request.php file, without them I would still be trying to make them work.

Plus I've just noticed your server config file doesn't have '+' in "Options +FollowSymLinks", not the .htaccess file. Try that as well.

Also the site.php must have the same hostname as you entered during installation, i.e. if you typed in an IP address, the BASE_URL must be the IP address.
silverbenz replied on at Permalink Reply
Hi linuxoid,

Digital Pacific are my hosting provider also.

Just to clarify: If I'm logged in as admin (or anyone else) and just viewing the site then pretty URLs work fine. The only time I see /index.php/ in the URI is when I'm viewing the C5 Administration pages (ie. Dashboard, Sitemap, Sitewide Settings, Add Functionality, etc). I'm not concerned about that as no site visitor ever sees those areas anyway.

As a side note, it's interesting (and really good) that DP helped you out with the 'request.php' file as they told me when I asked if the system supported C5 that they wouldn't be able to help with Concrete5 issues. Nice to see a service provider go the extra step when they don't have to.

Cheers,
Ben.
linuxoid replied on at Permalink Reply
linuxoid
Ah, yes, you're right. But who cares about pretty admin URLs?

Digital Pacific helped me quite a few times. I'm very very impressed with their support. And not just support, but knowledge as well. I'd bet that 99.9% wouldn't have even heard of Concrete5, not to mention fixing some nice-to-have features. I'd recommend them to anyone.
bunjigum replied on at Permalink Reply
Wow... What you just said is my exact site setup scenario that made me post here in the first place. Then I guess I can say there is no problem with my pretty url setup right from the start. Weeww...

Thanks Ben and Linuxoid for clarifying! I really appreciate all your help! Today is my day 2 learning concrete5 :)
pgee replied on at Permalink Reply
hi there,

Where do I put Options +FollowSymLinks??

I appreciate this thread is really old now..but I have this problem after my lovely host godaddy upgraded apache from 2.2 to 2.4. When I put in index.php before paths off the main site address all works fine but all links on the web pointing to my site and within my site fail.

I can get the site to work without pretty urls turned on but all addresses have index.php before them.

With it turned on I can't get addresses to work without index.php in.
I've tried dozens of .htaccess updates including the ones on here.
I have updated the request.php as in here ( its very long on my server - so I've totally copied over with the couple of lines and also tried inserting the lines where they kinda exist - if that makes sense) wasn't sure if a total rewrite or insert into the file was needed.

What I don't get is the Options +FollowSymLinks bit.

Do you mean server file as in my site.php or are you talking another file somewhere else.

BTW I'm on shared hosting. If it's relevant fast CGI is turned on.

Thanks so much - it's driving me nuts..
ThomasJ replied on at Permalink Reply
ThomasJ
I am searching for the answer to a Pretty URL issue myself. I looked at the file, concrete/libraries/request.php, and it is an empty class extention. I put this code in the extension and it broke c5. I am running c5.6. So, this apperas to be a version sensitive solution.
AEstable replied on at Permalink Reply
Brilliant! thanks for this fix. This had been driving me crazy! This is simple and it works like a charm!

Cheers,
Axel
linuxoid replied on at Permalink Reply
linuxoid
This An In Depth Guide to mod_rewrite for Apache may be useful:

http://net.tutsplus.com/tutorials/other/a-deeper-look-at-mod_rewrit...
chr1573r replied on at Permalink Reply
Just wanna say thanks for posting this, helped me figure stuff out :)
msglueck replied on at Permalink Reply
msglueck
thanks got it working on shared hosting with 5.4.2 (and internationalization):

My code change in request.php is documented here:
http://www.concrete5.org/index.php?cID=204712&editmode=...
iLP replied on at Permalink Reply
iLP
Nothing I tried would work on fatcow hosting, until I stumbled upon this is in a buried thread:

"The problem with your rewrites is that apache thinks "index.php/foo/bar" is supposed to be a file, but of course it isn't :)
I'd suggest trying either

RewriteRule ^(.+)$ index.php?/$1


or

RewriteRule ^(.+)$ index.php/$1 [R]


Note the question mark in rule 1 and the new R flag in rule 2."
241Dining replied on at Permalink Reply
Thank you for this information!! I didn't have to make any of the other changes, the one and only change I made was to my .htaccess where I changed the line:

RewriteRule ^(.*)$ index.php/$1 [L]

to:
RewriteRule ^(.*)$ index.php/$1 [R,L]


In other words, I just changed the [L] to an [R,L] and that seems to be working great!
(seehttp://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_r... for details)

Edit: I have since realized that although this makes pretty URL's function (they are no longer broken), the pretty URL is not the final URL displayed in the browser. The browser displays the URL with the index.php in it. So it's not a complete solution.
pgee replied on at Permalink Reply
hi there,

Where do I put Options +FollowSymLinks??

I appreciate this thread is really old now..but I have this problem after my lovely host godaddy upgraded apache from 2.2 to 2.4. When I put in index.php before paths off the main site address all works fine but all links on the web pointing to my site and within my site fail.

I can get the site to work without pretty urls turned on but all addresses have index.php before them.

With it turned on I can't get addresses to work without index.php in.
I've tried dozens of .htaccess updates including the ones on here.
I have updated the request.php as in here ( its very long on my server - so I've totally copied over with the couple of lines and also tried inserting the lines where they kinda exist - if that makes sense) wasn't sure if a total rewrite or insert into the file was needed.

What I don't get is the Options +FollowSymLinks bit.

Do you mean server file as in my site.php or are you talking another file somewhere else.

BTW I'm on shared hosting. If it's relevant fast CGI is turned on.

Thanks so much - it's driving me nuts..