使用 htaccess 创建 SEO 友好的 URL



当我更改链接时 它向我显示一个错误页面。 也许我的网站有问题,你怎么看?我的网站上有网址:www.mywebsite.com/picture.php?1我想把它改成这样的东西:www.mywebsite.com/picture/1

这是我的.htaccess。

RewriteEngine on
rewritecond %{http_host} ^website.com [nc]
rewriterule ^(.*)$ http://www.mywebsite.com/$1 [r=301,nc]
RewriteRule ^contact/?$ contact.php [L]
RewriteRule ^terms/?$ terms.php [L]
**RewriteRule ^picture/(.*)/$ picture.php?$1 [L]**

请帮忙,我不知道问题出在哪里。

尝试添加

<base href="www.mywebsite.com" />

在页面顶部,这可能有效。

编辑:

尝试使用此重写规则

RewriteRule picture/(.*)/$ /picture.php?$1 [L, NC]

假设您的 htAccess 的第一部分有效,请将最后一行替换为以下内容:

   RewriteRule ^picture/(.*)$ /picture.php?$1 [NC]

最新更新