HTACCESS问题请让我知道我做错了什么

时间:2014-07-04 00:08:27

标签: php apache .htaccess mod-rewrite

我正在尝试重写此网址,但没有任何工作请告诉我我做错了什么.. 我需要重写URL,所以唯一要看的是关键字plase help

chopo.com.mx/promocion?codigoPromo=2&region=2&keyword=Perfil-Hormonal-1

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

## hide .php extension snippet

# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]

RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/$ http://chopo.com.mx/promocion.php?codigoPromo=$1&region=$2&keyword=$3

# To internally forward 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]

# To remove www header
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [L,R=301]

1 个答案:

答案 0 :(得分:0)

保持您的代码:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

## hide .php extension snippet

# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]

# To remove www header
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f    
RewriteRule ^promocion/([\w-]+)/?$ promocion.php?codigoPromo=2&region=2&keyword=$1 [L,QSA,NC]

# To internally forward 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]