[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

Re: Why I roll back with using mod_rewrite ?

Post by amin30b »

When I do tobik suggestion with this code :

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 ^cmsms/(.+).html$ webfront/index.php?page=$1 [QSA]
pages load with 404 Not Found error . :'(

when I do mark suggestion with this code :

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
RewriteBase /webfront
#Rewrites page.shtml as index.php?page
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
result is same as before (return to index page) . :-[

You can see live demos here (use utf-8 encoding for better view) :

http://www.iesolution.ir/webfront/  ---------------> My index page
http://www.iesolution.ir/webfront/index ... ml=support
http://www.iesolution.ir/webfront/support.html      ---------------> 404 error

Also when I use this code :

Code: Select all

RewriteEngine on
RewriteBase /webfront

# 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 ^(.+).html$ index.php?page=$1 [QSA]
result is same as before (return to index page) .

I have different content in my root and I can`t move cmsms to main root .
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 »

Hey you cheated ;) When your page is /webfront/... and your cmsms is /cmsms/... then try
RewriteRule ^webfront/(.+).html$ cmsms/index.php?page=$1 [QSA]
If  both is in /webfront then use
RewriteRule ^webfront/(.+).html$ webfront/index.php?page=$1 [QSA]
Last edited by tobik on Tue Sep 11, 2007 6:34 am, edited 1 time in total.
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 »

When your page is /webfront/... and your cmsms is /cmsms/... then try
I don`t see above sentences exactly .
Inside of webfront folder there are some files like index.php , config.php , fileoc.php and so on .
I`ve used this :
RewriteRule ^webfront/(.+).html$ webfront/index.php?page=$1 [QSA]
But still I receive 404 error .
Pierre M.

Re: Why I roll back with using mod_rewrite ?

Post by Pierre M. »

Hello,

RewriteBase /webfront should do it, as said above. Strange...

Where is your .htaccess ? /.htaccess or /webfront/.htaccess ?

Can you try RewriteLog in the .htaccess ?

Little idea :
if

Code: Select all

RewriteRule ^(.+)$ index.php?page=$1 [QSA]
can't do the job, I think
RewriteRule ^(.+)[red]\[/red].html$ index.php?page=$1 [QSA]
is better than

Code: Select all

RewriteRule ^(.+).html$ index.php?page=$1 [QSA]
Pierre M.
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 »

Well, the idea of rewriting is:
1. Get the browser URL
2. If it start with webfront/ and end with .html then
3. Rewrite it to webfront/index.php?page=xxx where xxx is anything between webfront/ and .html

Example
1. Browser URL is http://www.iesolution.ir/webfront/support.html
The rewriting begins with webfront/support.html
2. This line starts with webfront/ and ends with .html. Between is support
3. The rewritten line is webfront/index.php?page=support
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 »

Pierre is right about the dot in front of html! It is more exact when it is escaped. But it should work anyway.
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 »

Hey! You are using this?
http://www.iesolution.ir/webfront/index.php?xhtml=support

Use
RewriteRule ^webfront/(.+)\.html$ webfront/index.php?xhtml=$1 [QSA]

or
RewriteBase /webfront
RewriteRule ^(.+)$ index.php?xhtml=$1 [QSA]
Pierre M.

Re: Why I roll back with using mod_rewrite ?

Post by Pierre M. »

Yes, tobik is right :
You have changed the config.php standard setting

Code: Select all

$config['query_var'] = 'page';
to

Code: Select all

$config['query_var'] = 'xhtml';
BTW, check this too :

Code: Select all

$config['page_extension'] = '.html';
That way a standard RewriteBase should do it ;)

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 »

Wow , at last it succumbed  8)
Thanks all  :D
But let me hint this important note :
RewriteRule ^webfront/(.+)\.html$ webfront/index.php?xhtml=$1 [QSA]
doesn`t work ,
BUT
RewriteBase /webfront
RewriteRule ^(.+)$ index.php?xhtml=$1 [QSA]

works great !
numerous thanks  :)
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 »

amin30b wrote: But let me hint this important note :
RewriteRule ^webfront/(.+)\.html$ webfront/index.php?xhtml=$1 [QSA]
doesn`t work
I'm confused! Just checked that on my local test system and it worked ???

Anyway - great you did it ;D
Post Reply

Return to “CMSMS Core”