2014-01-13 106 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