Page 2 of 2

Re: Why I roll back with using mod_rewrite ?

Posted: Mon Sep 10, 2007 9:48 pm
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 .

Re: Why I roll back with using mod_rewrite ?

Posted: Tue Sep 11, 2007 6:27 am
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]

Re: Why I roll back with using mod_rewrite ?

Posted: Tue Sep 11, 2007 9:31 am
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 .

Re: Why I roll back with using mod_rewrite ?

Posted: Tue Sep 11, 2007 9:53 am
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.

Re: Why I roll back with using mod_rewrite ?

Posted: Tue Sep 11, 2007 9:57 am
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

Re: Why I roll back with using mod_rewrite ?

Posted: Tue Sep 11, 2007 10:00 am
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.

Re: Why I roll back with using mod_rewrite ?

Posted: Tue Sep 11, 2007 10:08 am
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]

Re: Why I roll back with using mod_rewrite ?

Posted: Tue Sep 11, 2007 10:24 am
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.

Re: Why I roll back with using mod_rewrite ?

Posted: Tue Sep 11, 2007 12:17 pm
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  :)

Re: Why I roll back with using mod_rewrite ?

Posted: Tue Sep 11, 2007 4:24 pm
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