无法使用.htaccess创建SEO友好的URls

时间:2018-02-28 18:39:32

标签: .htaccess mod-rewrite url-rewriting

我知道有类似的问题,但我已经尝试了其他问题的更多解决方案来解决这个问题,但没有结果,这就是为什么我问这个问题。非常感谢你!

如何重写网址
从:

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]

0 个答案:

没有答案