0

我在 url 重写时遇到了一些问题我使用它作为我在 htaccess 中重写的代码

RewriteEngine On
RewriteRule ^([^/]*)\.html$ /pages.php?id=$1 [L]

这是我的网址

studentsassignmenthelp.com/pages.php?id=Marketing-Assignment-Help

使用 url 重写后,我得到了这个

studentsassignmenthelp.com/Marketing-Assignment-Help.html

但我需要它没有像下面这样的 html

studentsassignmenthelp.com/Marketing-Assignment-Help

如果我使用以下代码删除 .html 而不是显示错误 500 服务器...

RewriteRule ^([^/]*)$ /pages.php?id=$1 [L]

我看到了一些示例,但在使用它们后显示 404 或 500 错误

4

3 回答 3

1

试试这个,

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !pages.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ pages.php?id=$1 [QSA,L]
于 2013-06-14T08:53:53.100 回答
0

试试这个:

RewriteEngine On
RewriteRule ^([^/]*)$ /pages.php?id=$1 [L]
于 2013-06-14T08:58:36.907 回答
0

重定向匹配 301 ^(.*).html $1

这对于删除任何 url 扩展名并避免链接断开非常有用。

于 2013-06-14T10:05:40.800 回答