大家好我有htaccess的问题。
我想从此网址domain.com/index?article=28&title=velky-biel-karlova-ves
(它没有index.php,因为我用htaccess隐藏.php扩展名。
我想要这个网址domain.com/clanok/28/velky-biel-karlova-ves
我使用了这段代码
我的htaccess文件:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^clanok/([\d]+)/([\w-]+)/?$ index.php?article=$1&title=$2 [NC,L]
RewriteBase /
## hide .php extension
# 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]
我的index.php文件:
<a href="index.php?article=<?php echo urlencode($row['id']); ?>&title=<?php echo createSlug($row['title']); ?>" title="">
它不起作用。
寻求帮助。
答案 0 :(得分:1)
尝试这样你还需要提一下index.php你的php hide规则与此不同,
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^clanok/([\d]+)/([\w-]+)/?$ index.php?article=$1&title=$2 [NC,L]
请确保此规则与您现有的规则不冲突。