重写动态网址 [英] rewrite dynamic url
问题描述
我有以下问题:
http://www.mydomain.com/articles.php?artid=89
应该成为: http://www.mydomain.com/mykeyword
我不介意,如果ID留在网址...这样的: http://www.mydomain.com/89/mykeyword
I dont mind if the id remain in the url...like: http://www.mydomain.com/89/mykeyword
我有以下的.htaccess的时刻:
I have the following .htaccess for the moment:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(mydomain\.com)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+news\.php [NC]
RewriteRule ^ mykeyword [R=301,L]
RewriteRule ^mykeyword/?$ news.php [L,NC]
以上部分就像一个魅力。
The above part works like a charm.
任何帮助会深深AP preciated。
Any help will be deeply appreciated.
问候,卓然
推荐答案
在你的.htaccess底部附加这些规则:
Append these rule at the bottom of your .htaccess:
RewriteEngine On
RewriteBase /turkexpo/
RewriteCond %{HTTP_HOST} ^(webone\.gr)$ [NC]
RewriteRule ^(.*)$ http://www.%1/turkexpo/$1 [R=302,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+turkexpo/news\.php [NC]
RewriteRule ^ mykeyword [R=302,L]
RewriteRule ^mykeyword/?$ news.php [L,NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+turkexpo/articles\.php\?artid=([0-9]+) [NC]
RewriteRule ^ %1/mykeyword? [R=302,L]
RewriteRule ^([0-9]+)/mykeyword/?$ articles.php?artid=$1 [L,NC,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+turkexpo/companies\.php\?fairid=([0-9]+)&ehallid=([0-9]+) [NC]
RewriteRule ^ companies/%1/%2? [R=302,L]
RewriteRule ^companies/([0-9]+)/([0-9]+)/?$ companies.php?fairid=$1&ehallid=$2 [L,NC,QSA]
这将转发的 / 89 / mykeyword
URI来 /articles.php?artid=89
和外部重定向它的反面。
This will forward a URI of /89/mykeyword
to /articles.php?artid=89
and externally redirect the opposite of it.
一旦你确定它正在改变 R = 302
到 R = 301
。
Once you make sure it is working change R=302
to R=301
.
这篇关于重写动态网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!