[solved]Why I roll back with using mod_rewrite ?

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.
User avatar
amin30b
Forum Members
Forum Members
Posts: 146
Joined: Sat Mar 31, 2007 8:02 am

[solved]Why I roll back with using mod_rewrite ?

Post 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 .
Last edited by amin30b on Tue Sep 11, 2007 12:23 pm, edited 1 time in total.
Pierre M.

Re: Why I roll back with using mod_rewrite ?

Post 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.
User avatar
amin30b
Forum Members
Forum Members
Posts: 146
Joined: Sat Mar 31, 2007 8:02 am

Re: Why I roll back with using mod_rewrite ?

Post 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 .
Last edited by amin30b on Sun Sep 09, 2007 10:05 am, edited 1 time in total.
tobik
Translator
Translator
Posts: 149
Joined: Thu Aug 16, 2007 6:18 pm

Re: Why I roll back with using mod_rewrite ?

Post by tobik »

For my understanding your last line in .htaccess should be

Code: Select all

RewriteRule ^(.+).html$ index.php?page=$1 [QSA]
User avatar
amin30b
Forum Members
Forum Members
Posts: 146
Joined: Sat Mar 31, 2007 8:02 am

Re: Why I roll back with using mod_rewrite ?

Post 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  :-[
tobik
Translator
Translator
Posts: 149
Joined: Thu Aug 16, 2007 6:18 pm

Re: Why I roll back with using mod_rewrite ?

Post 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.
User avatar
amin30b
Forum Members
Forum Members
Posts: 146
Joined: Sat Mar 31, 2007 8:02 am

Re: Why I roll back with using mod_rewrite ?

Post by amin30b »

RewriteLog rewrite.log
    RewriteLogLevel 2
Where should I place above code ? How could I turn on rewrite log?
tobik
Translator
Translator
Posts: 149
Joined: Thu Aug 16, 2007 6:18 pm

Re: Why I roll back with using mod_rewrite ?

Post by tobik »

Should be placed in httpd.conf
Pierre M.

Re: Why I roll back with using mod_rewrite ?

Post 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.
User avatar
amin30b
Forum Members
Forum Members
Posts: 146
Joined: Sat Mar 31, 2007 8:02 am

Re: Why I roll back with using mod_rewrite ?

Post 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 .
tobik
Translator
Translator
Posts: 149
Joined: Thu Aug 16, 2007 6:18 pm

Re: Why I roll back with using mod_rewrite ?

Post 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?
User avatar
amin30b
Forum Members
Forum Members
Posts: 146
Joined: Sat Mar 31, 2007 8:02 am

Re: Why I roll back with using mod_rewrite ?

Post 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
tobik
Translator
Translator
Posts: 149
Joined: Thu Aug 16, 2007 6:18 pm

Re: Why I roll back with using mod_rewrite ?

Post 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/ ?
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Why I roll back with using mod_rewrite ?

Post by Dr.CSS »

If it is in a subfolder...

RewriteBase /nameofsubfolder
tobik
Translator
Translator
Posts: 149
Joined: Thu Aug 16, 2007 6:18 pm

Re: Why I roll back with using mod_rewrite ?

Post by tobik »

The result is the same. Just don't mix up.
Post Reply

Return to “CMSMS Core”