Page 1 of 2
[solved]Why I roll back with using mod_rewrite ?
Posted: Sat Sep 08, 2007 10:06 pm
by amin30b
Hi all
I`ve enabled mod_rewrite for my website , but there is one problem :
when I call
www.mysite.com/support.html or any child url,it redirects to
www.mysite.com/index.html and loads content of index page but url in address bar doesn`t change
( it remains
www.mysite.com/support.html) .
I used .htaccess file that is placed in doc folder of CMSMS .
Re: Why I roll back with using mod_rewrite ?
Posted: Sat Sep 08, 2007 11:26 pm
by Pierre M.
Hello,
before activating pretty URLs, how was working your site ?
Have you followed
this procedure ?
Are there any other software along with CMSms ?
Are there any other .htaccess or rewrite mechanism ?
Please show the extract of your config.php about URLs.
Please show your .htaccess (to be sure what is in the folder... it shouldn't be long)
What is your webserver ?
Pierre M.
Re: Why I roll back with using mod_rewrite ?
Posted: Sun Sep 09, 2007 10:02 am
by amin30b
Before activating pretty urls all thing was OK .
Yes I read it .
Code: Select all
#Show mod_rewrite URLs in the menu? You must enable 'use_hierarchy' for this to work for modules
$config['assume_mod_rewrite'] = true;
#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '.html';
#If you don't use mod_rewrite, then would you like to use the built-in
#pretty url mechanism? This will not work with IIS and the {metadata} tag
#should be in all of your templates before enabling.
$config['internal_pretty_urls'] = false;
#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'] = true;
#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';
No,there is not any software along it .
No,there is not any other htaccess file .
Code: Select all
#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
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
My webserver is apache .
Re: Why I roll back with using mod_rewrite ?
Posted: Sun Sep 09, 2007 10:16 am
by tobik
For my understanding your last line in .htaccess should be
Code: Select all
RewriteRule ^(.+).html$ index.php?page=$1 [QSA]
Re: Why I roll back with using mod_rewrite ?
Posted: Sun Sep 09, 2007 11:29 am
by amin30b
tobik wrote:
For my understanding your last line in .htaccess should be
Code: Select all
RewriteRule ^(.+).html$ index.php?page=$1 [QSA]
I did it but still result is same as before

Re: Why I roll back with using mod_rewrite ?
Posted: Sun Sep 09, 2007 3:24 pm
by tobik
Turn on the rewrite log.
Code: Select all
RewriteLog rewrite.log
RewriteLogLevel 2
Then you can see what URL is sent to CMSMS. Try this URL in the browser and see if you still got the same result.
Re: Why I roll back with using mod_rewrite ?
Posted: Sun Sep 09, 2007 3:32 pm
by amin30b
RewriteLog rewrite.log
RewriteLogLevel 2
Where should I place above code ? How could I turn on rewrite log?
Re: Why I roll back with using mod_rewrite ?
Posted: Sun Sep 09, 2007 6:13 pm
by tobik
Should be placed in httpd.conf
Re: Why I roll back with using mod_rewrite ?
Posted: Sun Sep 09, 2007 8:36 pm
by Pierre M.
Your config.php seems ok and your .htaccess too.
I hope the rewritelog will give information (thank you tobik).
You can also try these
mod_rewrite tests.
Pierre M.
Re: Why I roll back with using mod_rewrite ?
Posted: Sun Sep 09, 2007 11:18 pm
by amin30b
Unfortunately I can`t access to httpd.conf file of my web server .
(I think cPanel doesn`t have an option for it),
Also I have read that post and related to it when I place these tags in .htaccess file:
Code: Select all
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
# 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]
when I call
www.mysite.com/cmsms/books.html , it automatically redirects that page
to
www.mysite.com . (Two level upper)
Now I`m suspecting to
RewriteBase / , But I don`t know correct instruction for it .
Re: Why I roll back with using mod_rewrite ?
Posted: Mon Sep 10, 2007 8:49 am
by tobik
I think we need more info about your installation.
- What do you have to type in the browser for page X with pretty url inactive?
- What do you want to type in the browser for page X with pretty url active?
- What is the root_url in your config.php?
- What is the root_path in your config.php?
Re: Why I roll back with using mod_rewrite ?
Posted: Mon Sep 10, 2007 1:08 pm
by amin30b
Hi tobik
Yes , I should place those here

1-
http://www.mysite.com/cmsms/index.php?page=books
2-
http://www.mysite.com/cmsms/books.html
3- $config['root_url'] = '
http://www.mysite.com/cmsms
4- $config['root_path'] = '/home/user/public_html/cmsms'
Now , it should be easy to find main reason of my problem .
Regards
Omid
Re: Why I roll back with using mod_rewrite ?
Posted: Mon Sep 10, 2007 2:15 pm
by tobik
OK, then this rewrite_rule should do it
Code: Select all
RewriteRule ^cmsms/(.+).html$ cmsms/index.php?page=$1 [QSA]
Why do you put cmsms in the subdirectory? Do you have different content in the root
http://www.mysite.com/ ?
Re: Why I roll back with using mod_rewrite ?
Posted: Mon Sep 10, 2007 4:06 pm
by Dr.CSS
If it is in a subfolder...
RewriteBase /nameofsubfolder
Re: Why I roll back with using mod_rewrite ?
Posted: Mon Sep 10, 2007 6:35 pm
by tobik
The result is the same. Just don't mix up.