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

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
ced64k
Forum Members
Forum Members
Posts: 17
Joined: Mon May 15, 2006 9:09 am

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

Post 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
Last edited by ced64k on Sun May 28, 2006 7:13 am, edited 1 time in total.
Russ
Power Poster
Power Poster
Posts: 813
Joined: Fri Nov 25, 2005 5:02 pm

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

Post 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
ced64k
Forum Members
Forum Members
Posts: 17
Joined: Mon May 15, 2006 9:09 am

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

Post by ced64k »

I tested without this code too > 5OO error
But I think it's specific with my hosting :s
ced64k
Forum Members
Forum Members
Posts: 17
Joined: Mon May 15, 2006 9:09 am

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

Post 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
Last edited by ced64k on Sat May 27, 2006 7:31 pm, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

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

Post by Dr.CSS »

do all your templates have  {metadata}  in the .....

  mark
Russ
Power Poster
Power Poster
Posts: 813
Joined: Fri Nov 25, 2005 5:02 pm

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

Post 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
ced64k
Forum Members
Forum Members
Posts: 17
Joined: Mon May 15, 2006 9:09 am

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

Post 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})
Russ
Power Poster
Power Poster
Posts: 813
Joined: Fri Nov 25, 2005 5:02 pm

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

Post 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
amygdela

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

Post 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.
Russ
Power Poster
Power Poster
Posts: 813
Joined: Fri Nov 25, 2005 5:02 pm

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

Post 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
Last edited by Russ on Sun May 28, 2006 5:47 pm, edited 1 time in total.
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

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

Post by Ted »

It's {metadata}.  :)
Locked

Return to “CMSMS Core”