Hi,
I have the following question which came to me today. How can I make the CMSMS make the address like:
instead of http://domain.com/?page=something
to be http://domain.com/something
Please help.
Address rewrite question
-
raednesh
Re: Address rewrite question
download the config.php from the your site root directory.
Change the following line:
$config['assume_mod_rewrite'] = false;
to
$config['assume_mod_rewrite'] = true;
This will make CMSMS use http://domain.com/something.shtml instead of http://domain.com/?page=something
Good luck
Change the following line:
$config['assume_mod_rewrite'] = false;
to
$config['assume_mod_rewrite'] = true;
This will make CMSMS use http://domain.com/something.shtml instead of http://domain.com/?page=something
Good luck
-
jd
Re: Address rewrite question
super! 10x!
but how can I make it without the .shtml at the end?
but how can I make it without the .shtml at the end?
-
raednesh
Re: Address rewrite question
this is a little tricker, there are two steps involved:
1- Make CMSMS output the links without the .shtml extension.
2- Configure the server to forward the new formart to the correct page.
The first part is easy: open the config.php file and change:
$config['page_extension'] = '.shtml';
to
$config['page_extension'] = '';
The first part is over, now the second part:
1- On the root directory you will find a file named .htaccess (if you don't find it, you are suppose to upload it from the doc directory of the source package of CMSMS, or you can create an empty text file named .htaccess).
2- Download that file and open it, it should be like this:
php_flag magic_quotes_gpc Off
php_flag register_globals Off
php_flag session.use_trans_sid Off
# Make sure you have Options FollowSymLinks
# and Allow on
RewriteEngine On
#Rewrites page.shtml as index.php?page
RewriteRule ^(.+)\.shtml$ index.php?page=$1 [QSA]
Change the following line:
RewriteRule ^(.+)\.shtml$ index.php?page=$1 [QSA]
to
RewriteRule ^(.+) index.php?page=$1 [QSA]
And you are all set, upload and enjoy search engine friendly urls
1- Make CMSMS output the links without the .shtml extension.
2- Configure the server to forward the new formart to the correct page.
The first part is easy: open the config.php file and change:
$config['page_extension'] = '.shtml';
to
$config['page_extension'] = '';
The first part is over, now the second part:
1- On the root directory you will find a file named .htaccess (if you don't find it, you are suppose to upload it from the doc directory of the source package of CMSMS, or you can create an empty text file named .htaccess).
2- Download that file and open it, it should be like this:
php_flag magic_quotes_gpc Off
php_flag register_globals Off
php_flag session.use_trans_sid Off
# Make sure you have Options FollowSymLinks
# and Allow on
RewriteEngine On
#Rewrites page.shtml as index.php?page
RewriteRule ^(.+)\.shtml$ index.php?page=$1 [QSA]
Change the following line:
RewriteRule ^(.+)\.shtml$ index.php?page=$1 [QSA]
to
RewriteRule ^(.+) index.php?page=$1 [QSA]
And you are all set, upload and enjoy search engine friendly urls
-
jd
Re: Address rewrite question
10x raednesh!
You are of great help!
However, it didn't quite worked our from the first time (and still doesn't work). I've done all as to what you said, but I get a Error 404: File not found.
Do you where might the problem be?
You are of great help!
However, it didn't quite worked our from the first time (and still doesn't work). I've done all as to what you said, but I get a Error 404: File not found.
Do you where might the problem be?
-
raednesh
Re: Address rewrite question
you get File not found error normally if there is something wrong with the rewrite rule. The one I wrote above will transfer a request like:
http://domain.com/something
to
http://domain.com/index.php?page=something.
Is this how your system setup or is CMSMS is under a sub-directory? If that's not the case, do you have a url I can check out?
http://domain.com/something
to
http://domain.com/index.php?page=something.
Is this how your system setup or is CMSMS is under a sub-directory? If that's not the case, do you have a url I can check out?
-
jd
Re: Address rewrite question
it is under the root/cms
like domain.com/cms
does this matter?
like domain.com/cms
does this matter?
Last edited by jd on Fri Sep 09, 2005 5:16 am, edited 1 time in total.
-
raednesh
Re: Address rewrite question
yes because in that case the rewrite rule should be:
RewriteRule ^(.+) cms/index.php?page=$1 [QSA]
instead of
RewriteRule ^(.+) index.php?page=$1 [QSA]
Try it and let me know.
RewriteRule ^(.+) cms/index.php?page=$1 [QSA]
instead of
RewriteRule ^(.+) index.php?page=$1 [QSA]
Try it and let me know.
-
jd
Re: Address rewrite question
nope. it didn't worked. I think that I've made a mistake somewhere in step 1 (though that I've made everything as told).
because when I remove the .htaccess (so rewrite rules are applied), and in the config.php leave the .shtml extension just to test
when I try domain.com/cms/new.shtml --> still shows me an Error 404
is there something else to be edited in the config.php besides the $config['assume_mod_rewrite'] = true;
because when I remove the .htaccess (so rewrite rules are applied), and in the config.php leave the .shtml extension just to test
when I try domain.com/cms/new.shtml --> still shows me an Error 404
is there something else to be edited in the config.php besides the $config['assume_mod_rewrite'] = true;
-
raednesh
Re: Address rewrite question
from your test site I can see that the CMSMS is using the .shtml, now you still need the .htaccess file to tell the server to redirect the .shtml requests to the correct page, so your .htaccess should look like:
php_flag magic_quotes_gpc Off
php_flag register_globals Off
php_flag session.use_trans_sid Off
# Make sure you have Options FollowSymLinks
# and Allow on
RewriteEngine On
#Rewrites page.shtml as index.php?page
RewriteRule ^(.+)\.shtml$ index.php?page=$1 [QSA]
If that didn't work, change the last line to:
RewriteRule ^(.+)\.shtml$ cms/index.php?page=$1 [QSA]
Keep us updated how it goes
php_flag magic_quotes_gpc Off
php_flag register_globals Off
php_flag session.use_trans_sid Off
# Make sure you have Options FollowSymLinks
# and Allow on
RewriteEngine On
#Rewrites page.shtml as index.php?page
RewriteRule ^(.+)\.shtml$ index.php?page=$1 [QSA]
If that didn't work, change the last line to:
RewriteRule ^(.+)\.shtml$ cms/index.php?page=$1 [QSA]
Keep us updated how it goes
-
jd
Re: Address rewrite question
Well, 10x to raednesh, we've worked out the solution to my problem is the following:
The .htaccess file should look like this:
php_flag magic_quotes_gpc Off
php_flag register_globals Off
php_flag session.use_trans_sid Off
# Make sure you have Options FollowSymLinks
# and Allow on
RewriteEngine On
rewritecond %{REQUEST_FILENAME} !^(.+)\admin
#Rewrites page.shtml as index.php?page
RewriteRule ^(.+) /cms/index.php?page=$1 [QSA]
The .htaccess file should look like this:
php_flag magic_quotes_gpc Off
php_flag register_globals Off
php_flag session.use_trans_sid Off
# Make sure you have Options FollowSymLinks
# and Allow on
RewriteEngine On
rewritecond %{REQUEST_FILENAME} !^(.+)\admin
#Rewrites page.shtml as index.php?page
RewriteRule ^(.+) /cms/index.php?page=$1 [QSA]
