Aller au contenu

Apache config et URL rewrite

Featured Replies

Posté(e)

Bonjour!

J'ai la cabôche qui va exploser!

J'ai un vhost qui doit faire de l'URL rewriting pour faire un truc du style :

www.monserveur/ftp/toto.txt en www.monserveur/scpt.php?id=toto.txt

J'essaye un truc du style :

<VirtualHost *:83>

DocumentRoot "/var/www/ftp"

ErrorLog None

<IfModule mod_rewrite.c>

Options +FollowSymLinks

Options +Indexes

RewriteEngine ON

RewriteCond %{REQUEST_URI} ^/ftp*

RewriteRule ^ftp/([^.]+) scpt.php?id=$0 [L]

</IfModule>

</VirtualHost>

Mais je me paye toujours un 404....

Posté(e)

selon que tu veux affichier le contenu du fichier ou lance un telechargement auto

il te faut pour le premier

utilise les liens symboliques par rapport a scpt.php genre

fopen de repertoireduficher/fichier.txt

ou pour le téléchargement

mettre ton fichier txt dans rep_fichier

et tu met ceci dans ton .htacess

   
Options +FollowSymLinks
Options +Indexes
RewriteEngine ON
RewriteCond %{REQUEST_URI} ^/ftp*
RewriteRule ^ftp/([^.]+) scpt.php?id=$0 [L]
RewriteRule ^re_fichier/(.*)$ rep_fichier/$1 [L]

ton fichier scpt.php récupère le fichier en utilisant http://tonsite.com/ftp/rep_fichier/tonfichier.txt

Posté(e)
  • Auteur

Ca marche!

J'ai mis tout ca dans un .htaccess

Et avec un mod_ftp, ca permet d'avoir un ftp avec contenu dynamique!!!

Posté(e)
  • Auteur

Arf, on change pas de domaine mais un poil plus complexe :

Voilà mon soucis : je dois avoir un proxycache sur le port 80 qui n’accepte que les demandes du type http://monproxy-cache/img=http%3A%2F%2Fsit...hemin%2Ffichier et renvoyer le fichier correspondant http://site/chemin/fichier

En gros ca donne un truc du style :

<IfModule mod_proxy.c>

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{REQUEST_URI} ^/img=*

RewriteRule ^/img=([^*]+)$ $0 [L,P]

RewriteLog /var/log/RewriteLog.log

</IfModule>

AllowEncodedSlashes on

ProxyRequests On

<Proxy *>

Order deny,allow

allow from all

# Allow from .example.com

</Proxy>

# Enable/disable the handling of HTTP/1.1 "Via:" headers.

# ("Full" adds the server version; "Block" removes all outgoing Via: headers)

# Set to one of: Off | On | Full | Block

ProxyRequests On

ProxyVia On

# To enable a cache of proxied content, uncomment the following lines.

# See http://httpd.apache.org/docs/2.2/mod/mod_cache.html for more details.

<IfModule mod_disk_cache.c>

CacheEnable disk /

CacheRoot "/var/cache/mod_proxy"

</IfModule>

<IfModule mod_mem_cache.c>

CacheEnable mem /

MCacheMaxObjectSize 1024000

MCacheSize 102400

</IfModule>

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{REQUEST_URI} ^/img=*

RewriteRule ^/img=([^*]+)$ $0 [L,P]

RewriteLog /var/log/RewriteLog.log

</IfModule>

Seulement Apache ne fait pas la réécriture et boucle sur lui-même….

Posté(e)
  • Auteur

Voilà la solution pas encore sécurisée...

<VirtualHost *:80>

ServerSignature Off

ServerName cache-ext

ErrorLog logs/cache-ext_error.log

CustomLog logs/cache-ext_access.log combined

<IfModule mod_proxy.c>

<LocationMatch "^[^/]">

Deny from all

</LocationMatch>

<IfModule mod_rewrite.c>

RewriteEngine On

# RewriteCond %{REQUEST_URI} ^/img=(.+)$

RewriteRule ^/img=(.+)$ $1 [L,P]

RewriteLog /var/log/RewriteLog.log

</IfModule>

AllowEncodedSlashes on

ProxyRequests On

ProxyVia On

<IfModule mod_disk_cache.c>

CacheEnable disk /

CacheRoot "/var/cache/mod_proxy"

</IfModule>

<IfModule mod_mem_cache.c>

CacheEnable mem /

MCacheMaxObjectSize 1024000

MCacheSize 102400

</IfModule>

<proxy *>

# deny from all

</proxy>

<proxymatch ^/img=(.+)$>

allow from all

</proxymatch>

</IfModule>

</VirtualHost>

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.