Page 1 of 1

Pretty URLs : how to remove /index.php/ ?

Posted: Sat May 27, 2006 5:40 pm
by ced64k
Hi,

I'll want to remove /index.php/ in my url, like this:

http://mysite.com/index.php/home/ will become http://mysite.com/home/, like on this site.

I'm using CMSMS 0.13 Final.

I try the Russ' method, but I've got a 500 Internal Server Error.

config.php :

Code: Select all

$config['assume_mod_rewrite'] = true;
$config['page_extension'] = '/';
$config['internal_pretty_urls'] = false;
$config['use_hierarchy'] = true;
htaccess :

Code: Select all

#Config for CMS
RewriteEngine On

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
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 [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
(I have only this code in my htaccess file)

mod_rewrite work on my hosting (ovh.com), for example, the "no-www" code works fine.

Code: Select all

 RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
If someone can help me... thanks  ;D

Re: Pretty URL : how remove /index.php/ ?

Posted: Sat May 27, 2006 5:55 pm
by Russ
if you remove


RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]


Does it work e.g. no 500 error?

I've got to go now but will be back tomorrow

Russ

Re: Pretty URL : how remove /index.php/ ?

Posted: Sat May 27, 2006 6:06 pm
by ced64k
I tested without this code too > 5OO error
But I think it's specific with my hosting :s

Re: Pretty URL : how remove /index.php/ ?

Posted: Sat May 27, 2006 6:19 pm
by ced64k
I progress  :D
With my hosting (ovh.com) I have to an / before index.php, like this :

RewriteRule ^(.+)$ /index.php?page=$1 [QSA]

It works, but now I've a problem with the css link and images, except on the homepage.

Edit: Now, it works for the css/images too  ;D

I've put this in config.php:

Code: Select all

$config['assume_mod_rewrite'] = true;
$config['page_extension'] = '/';
$config['internal_pretty_urls'] = true;
$config['use_hierarchy'] = true;
And the {metadata} in my template, for base href tag

Re: Pretty URL : how remove /index.php/ ?

Posted: Sat May 27, 2006 7:28 pm
by Dr.CSS
do all your templates have  {metadata}  in the .....

  mark

Re: Pretty URL : how remove /index.php/ ?

Posted: Sun May 28, 2006 6:38 am
by Russ
If you are using (which you need to use to get the url you want)

Code: Select all

$config['assume_mod_rewrite'] = true;
then this should be false

Code: Select all

$config['internal_pretty_urls'] = false;
Certainly put in the {metadata} tag in your template and view the page code to see if it produces the base tag, something like:

Code: Select all

<base href="http://localhost/cms/" />
If it doesn't appear. then use the metabase tag from the 0.13 beta4 (I had problems) although it maybe fixed in SVN.

Also on one of the hosts I use, I had to add

Code: Select all

RewriteBase /
before the other stuff, under the mod-rewrite bit, to my .htaccess code - not entirely sure why though as it shouldn't be needed.

Hope this helps

Russ

Re: Pretty URL : how remove /index.php/ ?

Posted: Sun May 28, 2006 7:12 am
by ced64k
Thanks Russ, but it works now for me with $config['internal_pretty_urls'] = true; (maybe it's illogical ?)
I have URLs like mysite.com/category/subcategory/page
If I set it to false, css/images links are broken (I put RewritingBase / and {metadata})

Re: Pretty URLs : how to remove /index.php/ ?

Posted: Sun May 28, 2006 7:22 am
by Russ
Check to see if the metadata tag is actually working ! It doesn't appear to be on my systems with 0.13 (worked fine in 0.13 beta4) I just copied over the metadat tag (from the older version) into the plugin directiry - all was then fine with images :) I think this is the best way to do it :)

Russ

Re: Pretty URLs : how to remove /index.php/ ?

Posted: Sun May 28, 2006 7:49 am
by amygdela
you need to add a base href to the header of your HTML page, otherwise the links to your CSS and images are gone.

Re: Pretty URLs : how to remove /index.php/ ?

Posted: Sun May 28, 2006 12:11 pm
by Russ
amygdela, it is my understanding that the {metadata} ( Yes is it Ted, sorry :-) ) tag inserts the base reference or you can do it manually?

Russ

Re: Pretty URLs : how to remove /index.php/ ?

Posted: Sun May 28, 2006 12:36 pm
by Ted
It's {metadata}.  :)