我有一个网站在没有seo的情况下运行,我将链接更改为seo URL。我创建seo链接并将它们保存在数据库中。usaqe是:seo_url,php部分很好,但htaccess设置有问题。我读了很多关于htaccess设置的文章和问题,毕竟我找到了这个无法正常工作的解决方案。
特别是在Upanel分页部分需要一些帮助。Upanel是一个文件夹。
最接近的答案是:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^home/?$ index.php [NC,L]
RewriteRule ^contact/?$ contact.php [NC,L]
RewriteRule ^Upanel/?$ Upanel/account.php [NC,L]
RewriteRule ^Upanel/page/?$ Upanel/account.php?page=$1[L]
RewriteRule ^reset-password/?$ forgot.php [NC,L]
RewriteRule ^change-password/?$ resetpass.php [NC,L]
RewriteRule ^user/?$ login.php [NC,L]
RewriteRule ^search/?$ search.php [NC,L]
RewriteRule ^hr-search/?$ ik.php [NC,L]
RewriteRule ^sitemap/?$ rss.php [NC,L]
RewriteRule ^([a-zA-Z0-9_-]+)/?$ detail.php?p=$1 [NC,L]
RewriteRule ^category/([a-zA-Z0-9_-]+)/?$ categories.php?q=$1 [NC,L]
感谢的帮助
对于所有列出的规则,不需要重写条件(RewriteCond(。
阅读下面示例中的注释。
RewriteEngine On
# ^home index.php :request "starts with home"(^home) redirected to index.php,
# [NC,L] search is case insensitive(ie it also matches Home,hOme etc.
# [L] stop processing after this rule.
RewriteRule ^home index.php [NC, L]
# ^Upanel/page/ request starts with Upanel/page/
# (.*)$ "everything"(.*) after it "upto end"($) is stored in $1
RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]
刚刚修改了你的规则。
RewriteEngine On
RewriteRule ^home/ index.php [NC,L]
RewriteRule ^contact/ contact.php [NC,L]
RewriteRule ^Upanel/$ Upanel/account.php [NC,L]
RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]
RewriteRule ^reset-password/ forgot.php [NC,L]
RewriteRule ^change-password/ resetpass.php [NC,L]
RewriteRule ^user/$ login.php [NC,L]
RewriteRule ^search/$ search.php [NC,L]
RewriteRule ^hr-search/$ ik.php [NC,L]
RewriteRule ^sitemap/$ rss.php [NC,L]
RewriteRule ^([a-zA-Z0-9_-]+)/ detail.php?p=$1 [NC,L]
RewriteRule ^category/([a-zA-Z0-9_-]+) categories.php?q=$1 [NC,L]
看看这个。
RewriteRule ^Upanel/ Upanel/account.php [NC,L]
RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]
这里的第二个重写规则永远不会起作用,因为每个匹配第二个条件的请求也匹配第一个条件和L标志,确保它在第一个条件时停止。如果以下任何一项都有效,请根据您的要求进行选择。
RewriteRule ^Upanel/$ Upanel/account.php [NC,L]
RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]
或
RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]
RewriteRule ^Upanel/ Upanel/account.php [NC,L]
有关重写规则的顺序,请参阅重写规则标志和应答器