Force mod_rewrite on manually typed-in URLs

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
Pierre M.

Re: Force mod_rewrite on manually typed-in URLs

Post by Pierre M. »

Hello,

pretty URLs are thrice in the documentation (the wiki needs help). My favorite is this one :
http://wiki.cmsmadesimple.org/index.php ... l_Settings
You can find usefull filtering information too.

Thank you for having read the documentation before posting. You are a cool user :-)

To your issue now : you want www.mydomain.com/index.php?page=alias be rewritten externaly /alias.html and I think you are right. Isn't this just a webserver external 301 redirect away ? A quick look at Apache's extern redirect hints to something like :

Code: Select all

RedirectMatch permanent ^/index.php?page=.*$ /$1.html
before all other rewritting rules.

Does this work for you ? If yes, please post your solution so we can improve the documentation. Thanks in advance and happy new year.

Pierre M.
Pierre M.

Re: Force mod_rewrite on manually typed-in URLs

Post by Pierre M. »

Hello again,

have a look at your Apache's logS, including RewriteLog.

Three ideas :
1)Put the RedirectMatch "before all other rewritting rules" hence before RewriteEngine.
2)Bug :

Code: Select all

$config['internal_pretty_urls'] = true;
should be

Code: Select all

$config['internal_pretty_urls'] = false;
as you are enabling mod_rewrite (it is either or).
3)here is another try :

Code: Select all

RedirectMatch permanent ^/index.php?page=(.+)$ /$1/
BTW, see my posts about trailing slashes.

Pierre M.
nuno

Re: Force mod_rewrite on manually typed-in URLs

Post by nuno »

$config['use_hierarchy'] = true;
nuno

Re: Force mod_rewrite on manually typed-in URLs

Post by nuno »

expected you  use the mle (multilanguage)?
if yes is different!

# COMMENT Monolingual rule and UNCOMMENT MLE rule

#Monolingual
RewriteRule ^(.+)$ index.php?page=$1 [QSA]

#multilanguage - MLE
#RewriteRule ^([^/]+)/(.+)$ index.php?page=$2&hl=$1 [QSA]
Pierre M.

Re: Force mod_rewrite on manually typed-in URLs

Post by Pierre M. »

Hello again,

it is not the fork, good, keep the mono one.
Karolis wrote:

Code: Select all

RedirectMatch permanent ^/index.php?page=(.+)$ /$1/
Still no luck :(

The URLs remain the same: if I go to kalbercentrale.eu/index.php?page=content it stays that way instead of being rewritten to  kalbercentrale.eu/content

Any more ideas? :)
Pierre M. wrote: have a look at your Apache's logS, including RewriteLog.
We need a rewritelog to know why the rewriting isn't launched.
And try full removing of trailing slashes :

Code: Select all

RedirectMatch permanent ^/index.php?page=(.+)$ /$1
Pierre M.
nuno

Re: Force mod_rewrite on manually typed-in URLs

Post by nuno »

I see  you site it is well
kalbercentrale.eu/lt/content-2

Clean your browser cache and the admin /
Last edited by nuno on Thu Jan 03, 2008 4:21 pm, edited 1 time in total.
nuno

Re: Force mod_rewrite on manually typed-in URLs

Post by nuno »

The site is absolutely normal it works with and without pretty-url ;)
Pierre M.

Re: Force mod_rewrite on manually typed-in URLs

Post by Pierre M. »

Karolis wrote: nuno, I know it works :) But I want it to rewrite non-pretty URL if I enter it by hand.
RedirectMatch permanent ^/index.php?page=(.+)$ /$1 before any other rewrite should do it. Dig arround your Apache conf to find if redirect is enabled. Try it with static URL and static page. When it works, then tune it to CMSms.
Karolis wrote: Pierre, I don't want to sound like a complete n00b, but can I access Apache logs if I am not the server admin? The site is hosted at dreamhost.com
Don't worry, n00bs don't read documentation and you have read it.
But I'm afraid you need to have access to logS and rewrite logS to fit the requirements. I don't know Dreamhost. Make redirect work without CMSms first.

Pierre M.
Pierre M.

Re: Force mod_rewrite on manually typed-in URLs

Post by Pierre M. »

Karolis wrote: So is it possible that rewrite rules work, but redirects don't?
According to http://httpd.apache.org/docs/2.2/mod/mo ... irectmatch
RedirectMatch relies on mod_alias.
Rewrite relies on mod_rewrite.
One can be enabled and the other one disabled. Talk with your webserver administrator.

Pierre M.
Post Reply

Return to “The Lounge”