URL rewriting : un RewriteRule sans effet dans le htaccess

Nouveau WRInaute
Bonjour,

je n'arrive pas à faire fonctionner une réécriture d'URL spécifique dans mon htaccess. Tous les modules concernés sont activés sous Apache.

Je souhaite que les adresses

Code:
/article/news.php?id=0000&date=0000

apparaissent ainsi

Code:
/article/numero ID/titre de la news


J'ai donc mis :

Code:
RewriteRule ^article/([0-9]*)/(.*)$ /article/news.php?id=$1&date=$2 [L]

Mais aucun effet...

Ai-je fait une erreur ?

Merci pour votre aide,
 
Nouveau WRInaute
Merci loubet.

Mais même constat malgré le rajout du /
C'est comme si je n'avais pas mis le rewriterule :/

J'arrive pas à comprendre où cela peut bien bloquer
 
WRInaute accro
Heu tu essaies bien d’accéder à /article/numero ID/titre de la news qd c'est fait ?
Les liens de ton site ne se mettent pas à jour auto (oui ça px paraître con mais combien de fois j'ai vu ça sur WRI ...)
 
Nouveau WRInaute
Bonjour Jean-Luc,

voici :

Code:
RewriteEngine On

RewriteBase /


RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.+)\.php[3]$ $1.php [QSA,L]

RewriteRule ^/article/([0-9]+)/(.*)$ /article/news.php?id=$1&date=$2 [L]

########## PROTECTION LECTURE REPERTOIRES #############
Options -Indexes


#####" protect the htaccess file
<files .htaccess>
order allow,deny
deny from all
</files>

# ------------------------------------------------------------------------------
# | Compression                                                                |
# ------------------------------------------------------------------------------

<IfModule mod_deflate.c>

    <IfModule mod_setenvif.c>
        <IfModule mod_headers.c>
            SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
            RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
        </IfModule>
    </IfModule>

    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    # Mark certain resources as been compressed in order to:
    #
    #  1) prevent Apache from recompressing them
    #  2) ensure that they are served with the
    #     `Content-Encoding: gzip` HTTP response header

    <IfModule mod_mime.c>
        AddEncoding gzip              svgz
    </IfModule>

    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    # Compress all output labeled with one of the following media types.

    # IMPORTANT: For Apache versions below 2.3.7 you don't need to enable
    # `mod_filter` and can remove the `<IfModule mod_filter.c>` & `</IfModule>`
    # lines as `AddOutputFilterByType` is still in the core directives.

    <IfModule mod_filter.c>
        AddOutputFilterByType DEFLATE application/atom+xml \
                                      application/javascript \
                                      application/json \
                                      application/ld+json \
                                      application/manifest+json \
                                      application/rss+xml \
                                      application/vnd.ms-fontobject \
                                      application/x-font-ttf \
                                      application/x-web-app-manifest+json \
                                      application/xhtml+xml \
                                      application/xml \
                                      font/opentype \
                                      image/svg+xml \
                                      image/x-icon \
                                      text/cache-manifest \
                                      text/css \
                                      text/html \
                                      text/plain \
                                      text/vtt \
                                      text/x-component \
                                      text/xml
    </IfModule>

</IfModule>

# ------------------------------------------------------------------------------
# | Expires headers                                                            |
# ------------------------------------------------------------------------------

# Serve resources with far-future expires headers.

# IMPORTANT: If you don't control versioning with filename-based cache
# busting, consider lowering the cache times to something like one week.

<IfModule mod_expires.c>

    ExpiresActive on
    ExpiresDefault                                      "access plus 1 week"

  # CSS
    ExpiresByType text/css                              "access plus 1 week"

  # Data interchange
    ExpiresByType application/json                      "access plus 0 seconds"
    ExpiresByType application/ld+json                   "access plus 0 seconds"
    ExpiresByType application/xml                       "access plus 0 seconds"
    ExpiresByType text/xml                              "access plus 0 seconds"

  # Favicon (cannot be renamed!) and cursor images
    ExpiresByType image/x-icon                          "access plus 1 week"

  # HTML components (HTCs)
    ExpiresByType text/x-component                      "access plus 1 month"

  # HTML
    ExpiresByType text/html                             "access plus 0 seconds"

  # JavaScript
    ExpiresByType application/javascript                "access plus 1 week"

  # Manifest files
    ExpiresByType application/manifest+json             "access plus 1 year"
    ExpiresByType application/x-web-app-manifest+json   "access plus 0 seconds"
    ExpiresByType text/cache-manifest                   "access plus 0 seconds"

  # Media
    ExpiresByType audio/ogg                             "access plus 1 month"
    ExpiresByType image/gif                             "access plus 1 month"
    ExpiresByType image/jpeg                            "access plus 1 month"
    ExpiresByType image/png                             "access plus 1 month"
    ExpiresByType video/mp4                             "access plus 1 month"
    ExpiresByType video/ogg                             "access plus 1 month"
    ExpiresByType video/webm                            "access plus 1 month"

  # Web feeds
    ExpiresByType application/atom+xml                  "access plus 1 hour"
    ExpiresByType application/rss+xml                   "access plus 1 hour"

  # Web fonts
    ExpiresByType application/font-woff                 "access plus 1 month"
    ExpiresByType application/vnd.ms-fontobject         "access plus 1 month"
    ExpiresByType application/x-font-ttf                "access plus 1 month"
    ExpiresByType font/opentype                         "access plus 1 month"
    ExpiresByType image/svg+xml                         "access plus 1 month"

</IfModule>

#etag
FileETag Size
 
B
blackfenix
Guest
Bonjour tout le monde j'ai un problème similaire.

J'ai un site (joomla) pour lequel j'ai fait des redirections d'ancienne URL vers les nouvelles et j'ai mis en début le fait de faire également en sorte que les url en non-www repoint sur les url en www. Mon soucis est que sur certaines URL je n'arrive pas à faire des redirection lorsque celles-ci sont soit sans les www soit lorsqu'il y a des variables à la con ?var=d....

Ci-dessous mon htaccess :

RewriteEngine On

RewriteCond %{HTTP_HOST} ^monsite.fr$ (<- ca fonctionne)
RewriteRule ^(.*) http://www.monsite.fr/ [QSA,L,R=301] (<- ca fonctionne)


Si URL de base est
http://www.monsite.fr/chapitre1/mon-ancien-article-xx, la ré-écriture ci-dessous fonctionne
RedirectPermanent /chapitre1/mon-ancien-article-xx http://www.monsite.fr/chapitre1/le-bon-article-xx (<- ca fonctionne)

Par contre si l'URL est du type :
http://monsite.fr/chapitre1/mon-ancien-article-xx, la ré-écriture ne fonctionne plus
RedirectPermanent /chapitre1/mon-ancien-article-xx http://www.monsite.fr/chapitre1/le-bon-article-xx (<- fonctionne pas)

je pense que le problème viens du fait que la condition des non-www vers www qui doit prendre le pas, elle doit pas être bien écrite (attention sur pas un expert en ré-ecriture justement)


L'autre problème c'est que j'ai des URL du type :
ex . http://www.monsite.fr/chapitre-xx/mapage?format=feed&type=rss
RedirectPermanent /chapitre-xx/mapage?format=feed&type=rss http://www.monsite.fr/chapitre-xx/nouvelle-page (<- fonctionne pas)

En fait j'aimerais passer outre et faire en sorte qu'une URL spécifique http://www.monsite.fr/chapitre-xx/mapage?format=feed&type=rss pointe sur une nouvelle URL
Je pensais q'un simple
RedirectPermanent http://www.monsite.fr/chapitre-xx/mapage?format=feed&type=rss http://www.monsite.fr/ma-nouvelle-url
pourrais fonctionner correctement mais je me trompe apparemment lourdement, ce serait pourtant si simple.

Même en les mettant en tout début de htaccess avant la redireciton des non-www vers le www et bien cela fonctionne pas.

Help me please....
Neo
 
Nouveau WRInaute
Hello,

ton rewrite semble bien ecrit :

voici le mien qui fonctionne parfaitement :

Code:
RewriteCond %{HTTP_HOST} ^monsite.com$
RewriteRule ^(.*) http://www.monsite.com/$1 [QSA,L,R=301]

A+
 
Discussions similaires
Haut