Page 1 of 1

pretty urls without the index.php?

Posted: Mon Oct 25, 2010 10:55 pm
by Metal Beryl
Hello,

I have followed the guide to set up pretty urls and it has almost worked. How do I get rid of the index.php in the url http://localhost/cms/[b]index.php[/b]/blog/

.htaccess file

Code: Select all

  Options +FollowSymLinks
  RewriteEngine on
  RewriteBase /cms
 
  # 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]
config.php

Code: Select all

$config['url_rewriting'] = 'internal';

#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '/';

#If you're using the internal pretty url mechanism or mod_rewrite, would you like to
#show urls in their hierarchy?  (ex. http://www.mysite.com/parent/parent/childpage)
$config['use_hierarchy'] = false;

#If using none of the above options, what should we be using for the query string
#variable?  (ex. http://www.mysite.com/index.php?page=somecontent)
$config['query_var'] = '/';
Thanks
Jane

Re: pretty urls without the index.php?

Posted: Tue Oct 26, 2010 4:19 am
by Nullig
Change:
    $config['url_rewriting'] = 'internal';
to:
    $config['url_rewriting'] = 'mod_rewrite';

Nullig

Re: pretty urls without the index.php?

Posted: Tue Oct 26, 2010 6:20 am
by Metal Beryl
Thanks Nullig,

If I do that I get 'The requested URL was not found on this server.' Error 404 when i navigate through the pages, only the home page (index) works. Any ideas why it would do that?

Thanks
Jane

Re: pretty urls without the index.php?

Posted: Tue Oct 26, 2010 9:31 am
by Dr.CSS
Is this on your computer or on a server?...

I don't think pretty URLs work on a PC install, and I see no reason to use it on a PC install...

Re: pretty urls without the index.php?

Posted: Tue Oct 26, 2010 1:03 pm
by Metal Beryl
I'm testing it out on both. My client wants easier urls to use on printed material and as the website is live I've been attempting to get it working on my localhost before risking in on the live website. I have got the url index.php/page working on the live website just cant get rid of the index.php part, tried all kinds.

Re: pretty urls without the index.php?

Posted: Tue Oct 26, 2010 4:17 pm
by Dr.CSS
Take the htaccess.txt out of the doc folder in root and put in root, rename it to .htaccess, change config to...

$config['url_rewriting'] = 'mod_rewrite';  internal keeps the index.php

#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '.html'; or some other ext. / is not an extension

#If you're using the internal pretty url mechanism or mod_rewrite, would you like to
#show urls in their hierarchy?  (ex. http://www.mysite.com/parent/parent/childpage)
$config['use_hierarchy'] = false;

#If using none of the above options, what should we be using for the query string
#variable?  (ex. http://www.mysite.com/index.php?page=somecontent)
$config['query_var'] = 'page'; or leave blank