2010-08-19 7 views

Répondre

0
RewriteRule ^page.php$ http://www.site.com/page/ [QSA,L] 
RewriteRule ^page$ http://www.site.com/page/ [QSA,L] 

Peut-être que cela fonctionnera.

1

Pour le domaine:

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC] 
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L] 

Pour votre premier répertoire:

RewriteRule ^/([^/]*)(\.php)? /$1/ 
+0

Cela semble rediriger de 'http: // domain.com/page' à' http: // www.domain.com', ne pas conserver la page. – Robert

0

Cela devrait faire ce que vous vouliez:

RewriteEngine On 

RewriteCond %{THE_REQUEST} ^[A-Z]+\s/([^\s]*?)\.php [OR] 
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/([^\s]*?[^/\s])\s [OR] 
RewriteCond %{HTTP_HOST} !^www\. 
RewriteCond %{HTTP_HOST}/%1 ^(www\.)?(.*?)/?$ 
RewriteRule^http://www.%2/ [R=301,L] 

# Assuming you want to write the request back to page.php too... 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)/$ $1.php 
0

réponse Tim est le plus proche, mais il fait aussi ajoute la barre oblique aux images et css ...

Donc, en prenant la réponse de Tim, et l'édition un peu il nous donne:

RewriteEngine on 

RewriteRule \.(css|jpe?g|gif|png)$ - [L] 

RewriteCond %{THE_REQUEST} ^[A-Z]+\s/([^\s]*?)\.php [OR] 
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/([^\s]*?[^/\s])\s [OR] 
RewriteCond %{HTTP_HOST} !^www\. 
RewriteCond %{HTTP_HOST}/%1 ^(www\.)?(.*?)/?$ 
RewriteRule^http://www.%2/ [R=301,L] 

# Assuming you want to write the request back to page.php too... 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)/$ $1.php 

qui devrait fonctionner!