RewriteRule重命名url与参数不起作用

问题描述 投票:0回答:1

我想要这个网址:http://www.website.com/article?a=article-id

成为这个网址:http://www.website.com/article-id

我试过这段代码:

RewriteEngine On
RewriteRule ^([^/]*)\$ /article?a=$1 [L]

我也试过这个:

RewriteRule ^([a-z-/]+)$ article?a=$1 [QSA]

没有人工作。

谢谢

这是我在.htaccess的代码

AddHandler application/x-httpd-php54 .php .php5 .php4 .php3  

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

errorDocument 404 http://www.website.com

Options -Indexes


RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [NC,L]
php .htaccess mod-rewrite
1个回答
0
投票

请尝试重写:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^\/article$
RewriteCond %{QUERY_STRING} ^a=(.*)
RewriteRule ^(.*)$ /%1? [L,QSA]
© www.soinside.com 2019 - 2024. All rights reserved.