2014-01-13 105 views
1

我需要你的幫助。刪除擴展程序後重寫url

我不得不重寫擴展刪除後的動態URL的問題,我已經重寫這個URL,但沒有作品:

的.htaccess這樣的:

<IfModule mod_rewrite.c> 
Options -Multiviews 
Options +FollowSymLinks 

RewriteEngine On 
RewriteBase/

#add www 1 
RewriteCond %{HTTP_HOST} !^www\.mondomain\.com$ [NC] 
RewriteRule ^(.*)$ http://www.mondoamin.com/$1 [R=301,L] 

#remove .php extension 2 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/$ /$1 [R=301,L] 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php [L] 

# Removes index.php from ExpressionEngine URLs 3 
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC] 
RewriteCond %{REQUEST_URI} !/system/.* [NC] 
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L] 

# Directs all EE web requests through the site index file 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l 
RewriteRule ^(.*)$ /index.php/$1 [L] 

#rewrite url 4 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /article\.php\?id_ article =([^&\ ]+)([^\ ]*) 
RewriteRule ^/article/%1?%2 [L,R=301] 

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*[^.#?\ ]+\.php([#?][^\ ]*)?\ HTTP/  
RewriteRule ^(([^/]+/)*[^.]+)\.php $1 [R=301,L] 
</IfModule> 

結果: 1 + 2 + 3工作正常,但4不是工作

在此先感謝

回答

0

嘗試重新排序的規則和內部重寫之前保持301個規則:

Options -Multiviews 
Options +FollowSymLinks 

RewriteEngine On 
RewriteBase/

#add www 1 
RewriteCond %{HTTP_HOST} !^www\.mondomain\.com$ [NC] 
RewriteRule ^(.*)$ http://www.mondoamin.com/$1 [R=301,L] 

#rewrite url 4 
RewriteCond %{THE_REQUEST} /article\.php\?id_article=([^&\ ]+)([^\ ]*) 
RewriteRule^/article/%1?%2 [L,R=301] 

RewriteRule ^article/([^/]+)/?$ /article.php?id_article=$1 [L,QSA] 

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*[^.#?\ ]+\.php([#?][^\ ]*)?\ HTTP/  
RewriteRule ^(([^/]+/)*[^.]+)\.php $1 [R=301,L] 

#remove .php extension 2 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/$ /$1 [R=301,L] 

# Removes index.php from ExpressionEngine URLs 3 
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC] 
RewriteCond %{REQUEST_URI} !/system/.* [NC] 
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L] 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php [L] 

# Directs all EE web requests through the site index file 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l 
RewriteRule ^(.*)$ /index.php/$1 [L] 
+0

我害怕。它不工作! – Nashen

+0

這個.htaccess的位置和它不工作的URL是什麼? – anubhava

+0

.htaccess位於我的網站的根目錄中。這裏是不起作用的網址:RewriteCond%{THE_REQUEST}^[AZ] {3,9} \ /article\.php\?id_ article =([^&\] +)([^ \] *) RewriteRule ^/article /%1?%2 [L,R = 301] – Nashen

0

這是我最後的.htaccess代碼:
選項-Multiviews

選項+的FollowSymLinks

RewriteEngine敘述在

RewriteBase/

加上www

的RewriteCond%{HTTP_HOST} ^!www.mondomain.fr $ [NC]

重寫規則^(。*)$ http://www.mondomaine.fr/ $ 1 [R = 301,L]

重寫動態URL

的RewriteCond %{THE_REQUEST} /article.php\?id_article=([^ & \] +)([^ \] *)

重寫規則^ /條/%1?%2 [L,R = 301]

RewriteRule^article /([^ /] +)/?$ /article.php?id_article=$1 [L,QSA]

RewriteCond%{THE_REQUEST}^[AZ] + \ /([^ /] + /)[^。#?\] + .php([#?] [^ \]

重寫規則^(([^ /] + /)* [^。] +)。PHP $ 1 [R = 301,L]

除去PHP擴展

的RewriteCond%{REQUEST_FILENAME}! -d

重寫規則^(。*)/ $/$ 1 [R = 301,L]

移除index.p馬力從ExpressionEngine網址

的RewriteCond%{THE_REQUEST}^GET。*的index.php [NC]

的RewriteCond%{REQUEST_URI}!/系統/.* [NC]

重寫規則(。 ?)index.php/(。*)/ $ 1 $ 2 [R = 301,NE,L]

RewriteCond%{REQUEST_FILENAME}!-d

的RewriteCond%{} REQUEST_FILENAME -f .PHP

重寫規則^(。*)$ $ 1.PHP [L]

通過站點索引文件將所有EE Web請求

的RewriteCond%{} REQUEST_FILENAME!-f

的RewriteCond%{} REQUEST_FILENAME!-d

的RewriteCond%{} REQUEST_FILENAME!-l

重寫規則^(。*)$ /index.php/$1 [L]

+0

有什麼想法,不好意思anubhava我已經加了.htaccess作爲迴應,由於文件的長度。 – Nashen