2017-10-12 7 views
2

Je veux transmettre www.myapp.com à myapp.com.Django transmettre www.domain.com à domain.com avec fastcgi RewriteRule

Mon actuelle htaccess

AddHandler fcgid-script .fcgi 
RewriteEngine on 
# Set up static content redirect: 
RewriteRule static/(.+)$ myapp-folder/public/static/$1 
# The following two lines are for FastCGI: 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ application.fcgi/$1 [QSA,L] 

J'ai essayé d'ajouter des lignes ci-dessous au contenu ci-dessus

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

Mais il ne me donne pas la sortie que je veux. Sans fastcgi je peux juste remplacer ces lignes puisque mon application en dépend, comment puis-je ajouter cette redirection sans enlever la règle fcgi.

+2

Ajouter les nouvelles lignes avant les autres (après 'RewriteEngine on') – Croises

+0

@Croises l'afficherons comme réponse que je puisse accepter – silentprogrammer

Répondre

0

Vous devez d'abord rediriger:

AddHandler fcgid-script .fcgi 
RewriteEngine on 

# www.myapp.com to -> myapp.com 
RewriteCond %{HTTP_HOST} ^www\. [NC] 
RewriteRule^http://myapp.com%{REQUEST_URI} [NE,R=301,L] 

# Set up static content redirect: 
RewriteRule static/(.+)$ myapp-folder/public/static/$1 
# The following two lines are for FastCGI: 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ application.fcgi/$1 [QSA,L]