Page 1 of 1
[RESOLU]Rewriting
Posted: Fri Apr 24, 2009 2:38 pm
by rchollet
Bonjour, ou rebonjour.
Encore moi, j'ai un soucis cette fois pour le rewriting.
Je sais comment ca marche, j'ai fais des tests et ça fonctionne.
Sauf que dans mon URL j'ai en plus un §ion="l'id de mon menu".
URL de base : machin.com/index.php?page=truc
Mon URL : machin.com/index.php?page=truc§ion="1"
J'ai une adresse comme ça car ça me permet de changer de couleur suivant le menu choisit.
et quand je fait mon rewriting il ne s'effectue que sur le ""page=truc".
Peut t'on faire une "adresse propre" avec mon URL ?
Merci d'avance.
Re: Rewriting
Posted: Fri Apr 24, 2009 4:17 pm
by jce76350
Re: Rewriting
Posted: Tue Apr 28, 2009 5:09 pm
by Pierre M.
Je n'ai pas bien compris quelle est l'URL propre souhaitée.
Voyez peut être "QSA" dans la documentation de mod_rewrite Apache.
Pierre M.
Re: Rewriting
Posted: Wed Apr 29, 2009 7:36 am
by steph60
Mopi j'ai réussi à faire fonctionner l'url rewriting avec l'htaccess suivant à la racine de mon site :
Code: Select all
RewriteEngine On
#option to remove directory listings in all folder (avoid publishing unwanted contents)
Options -Indexes
# Deny access to config.php
# This can be useful if php ever breaks or dies
# Use with caution, this may break other functions of CMSms that use a config.php
# file. This may also break other programs you have running under your CMSms
# install that use config.php. You may need to add another .htaccess file to those
# directories to specifically allow config.php.
<Files "config.php">
order allow,deny
deny from all
</Files>
# URL Filtering helps stop some hack attempts
#IF the URI contains a "http:"
RewriteCond %{QUERY_STRING} http\: [OR]
#OR if the URI contains a "["
RewriteCond %{QUERY_STRING} \[ [OR]
#OR if the URI contains a "]"
RewriteCond %{QUERY_STRING} \] [OR]
#OR if the URI contains a "<__script__>"
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
#OR if the script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
#OR if any script is trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) [OR]
#OR if the URI contains UNION
RewriteCond %{QUERY_STRING} UNION [OR]
#OR if the URI contains a double slash
RewriteCond %{QUERY_STRING} // [OR]
#OR if the URI contains a *
RewriteCond %{QUERY_STRING} \*
#then deny the request (403)
RewriteRule ^.*$ - [F,L]
# End URL Filtering
# No sense advertising what we are running
ServerSignature Off
RewriteCond %{QUERY_STRING} http\: [OR]
RewriteCond %{QUERY_STRING} \[ [OR]
RewriteCond %{QUERY_STRING} \] [OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^.*$ - [F,L]
# CMSMS Rewriting
# Régles de réécriture pour la forme /parent/enfant/
# mais réécrit seulement si l'URL demandée n'est pas un fichier ou un répertoire
# ajout :
# la premier ligne permet de renommer les liens evrs les news et flux rss
RewriteRule ^News/rss(.+)$ index.php?page=News/rss$1 [S=1]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^([^/]+)/(.*)$ index.php?page=$2&hl=$1 [QSA]
RewriteRule ^(.+)(.html)?$ index.php?page=$1 [QSA]
et dans le fichier config.php
Code: Select all
#------------
#URL Settings
#------------
#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';
Re: Rewriting
Posted: Wed Apr 29, 2009 8:42 am
by rchollet
Merci pour ta réponse Steph60 !!
Ca va surement m'aider.
Par contre j'ai une autre question.
Comment tu as fait pour avoir ton "&h1" dans ton url?
Tu l'as mis dans ton gabarit menu a la suite de ton {$node->url} : url}&h1=truc". (c'est ce que j'avais fais au début, un peu "bidouilleux" tout ça !!!

)
Ou alors t'as rajouté une variable dans le config.php. Par exemple un truc comme ça :
$config['query_var'] = 'page';
$config['query_var'] = 'h1';
(j'ai testé ca marche pas).

Merci d'avance.
Re: Rewriting
Posted: Wed Apr 29, 2009 9:17 am
by steph60
euh je comprends pas trop le &h1
en fait, au lieu de :
machin.com/index.php?page=truc
j'ai
machin.com/truc.html
Re: Rewriting
Posted: Wed Apr 29, 2009 9:33 am
by rchollet
Le "&hl" orrespond à ce qu'il se trouve à la fin dans ton code du .htaccess
Code: Select all
#RewriteRule ^([^/]+)/(.*)$ index.php?page=$2&hl=$1 [QSA]

Re: Rewriting
Posted: Wed Apr 29, 2009 9:57 am
by steph60
c'est une ligne de commentaire qui ne sert à rien tu peux la virer (petit oubli de ma part)
Re: Rewriting
Posted: Wed Apr 29, 2009 9:59 am
by jce76350
re,
@ steph60: Usine a gaz mais bon
Il y a un modéle de htaccess dans le dossier /doc de cmsms
pour information
Possibilités de définir les URLs
Re: Rewriting
Posted: Wed Apr 29, 2009 10:29 am
by rchollet
Ok merci pour vos réponses !!!!! Mais ça ne répond pas à ce que je cherche.
Pour le rewriting je sais comment on fait mantenant !!!
En ce moment je fais des tests pour pouvoir comprendre tout le fonctionnement de CMSMS et pour voir ces limites.
Et j'essaye de savoir si il est possible de mettre un query String en plus de page="alias de la page" dans l'url.
Savoir si c'est possible d'avoir ca :
http://localhost/halle_veaux/index.php? ... tion="truc"[/b].
Merci.
J'ai fais des tests mais c'est de la bidouille donc pas optimisé.
J'ai cherché de partout mais je trouve rien.

Re: Rewriting
Posted: Wed Apr 29, 2009 11:03 am
by steph60
jce76350 wrote:
re,
@ steph60: Usine a gaz mais bon
Il y a un modéle de htaccess dans le dossier /doc de cmsms
pour information
Possibilités de définir les URLs
usine à gaz mais qui marche alors que bon nombre de post donne des morceaux qui marche pas
ce htaccess permet l'urlrewriting et la protection du site, donc pour moi je prefere ça
Re: Rewriting
Posted: Tue May 05, 2009 2:03 pm
by Pierre M.
Pierre M. wrote:
peut être "QSA" dans la documentation de mod_rewrite Apache.
[RESOLU] Rewriting
Posted: Tue May 12, 2009 2:30 pm
by rchollet
Bonjour a tous !!
Désolé du reard de mes nouvelles !!
C'est bon mon problème est résolu j'avais mal configuré mon htaccess.
Voila Merci encore.
A bientôt.