我知道有类似的问题,但我已经尝试了其他问题的更多解决方案来解决这个问题,但没有结果,这就是为什么我问这个问题。非常感谢你!
如何重写网址
从:
http://www.imperialtranstur.md/mare?lang=ro&cat=bulgaria&tip=mare
到
http://www.imperialtranstur.md/ro/bulgaria/mare
这
http://www.imperialtranstur.md/hotele-mare?lang=ro&cat=albena
到
http://www.imperialtranstur.md/ro/hotele-mare/albena
这
http://www.imperialtranstur.md/hotel-mare?lang=ro&id=411
到
http://www.imperialtranstur.md/ro/hotel-mare/id=411
我尝试写的第一个链接:
RewriteRule ^mare/([0-9a-zA-Z_-]+)/([0-9a-zA-Z_-]+)/([0-9a-zA-Z_-]+)/ mare.php?lang=$1&cat=$2&tip=$3 [NC,L]
并在.php文件中写道:
<a href="mare.php?lang='.$_GET['lang'].'&cat='.strtolower($row["Tara"]).'&tip='.$row["tip"].'">'.$row["Tara"].'</a>
这是我的.htaccess文件,没有上述网址的重写规则: AddDefaultCharset utf-8 RemoveHandler .html .htm AddType application / x-httpd-php .php .htm .html .phtml 选项+ FollowSymLinks -MultiViews #打开mod_rewrite RewriteEngine On RewriteBase /
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
RewriteCond %{QUERY_STRING} !lang
RewriteRule (.*) $1?lang=ro [R=302,QSA,L]