我有一些问题与url重写我使用这个作为我的代码重写在htaccess
RewriteEngine On
RewriteRule ^([^/]*)'.html$ /pages.php?id=$1 [L]
这是我的url
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错误
试试这个,
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !pages.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ pages.php?id=$1 [QSA,L]
try this:
RewriteEngine On
RewriteRule ^([^/]*)$ /pages.php?id=$1 [L]
redirectMatch 301 ^ (. *) . html
1美元这是非常有用的,以删除任何url扩展和避免断开链接。