php - URL 重写内部服务器错误
问题描述
我正在尝试在我的类别页面上重写一个 url。
https://www.samedicalspecialists.co.za/category?category=breast-surgeon
我想做:
https://www.samedicalspecialists.co.za/category/breast-surgeon
我的 htaccess 文件中有这个
RewriteEngine On
RewriteRule ^category/([^/]*)$ /category?category=$1 [L]
当我单击类别时出现内部服务器错误,请帮助
更新完整的 htaccess 文件
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# if a file without .php extension is requested, rewrite it to .php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule (.*)$ $1.php [L]
# rewrite everything else (except /listing) to /listing?url=
RewriteCond %{REQUEST_FILENAME} !listing
RewriteRule ^([^.]+)$ /listing?url=$1 [L]
#categories
Options -MultiViews
RewriteRule ^category/([^/]*)$ /category?category=$1 [L]
其他规则仅适用于类别
解决方案
更改顺序:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#categories
RewriteRule ^category/([^/]*)$ /category?category=$1 [NC,L]
# if a file without .php extension is requested, rewrite it to .php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule (.*)$ $1.php [L]
# rewrite everything else (except /listing) to /listing?url=
RewriteCond %{REQUEST_FILENAME} !listing
RewriteRule ^([^.]+)$ /listing?url=$1 [L]
推荐阅读
- view - 如何访问 Revit 的视图模板属性并实时比较它们?
- debugging - Disassamble ELF 文件 - 加载特定二进制字符串的调试区域
- javascript - 是否可以从 v-for 循环外部访问 v-for 中变量的值?
- mysql - 将两列的对数计算为总量
- angular - 角度工具提示不适用于图标
- css - 如何通过使用 Less 将父选择器和前置选择器添加到所有样式规则来确定 CSS 文件的范围?
- amazon-web-services - AWS Neptune 主机未及时响应 - 检查服务器状态并再次提交
- excel - Excel VBA多次更改事件导致堆叠空间不足
- r - 将 R Dataframe 保存为基于对象的文件名
- selenium-ide - Selenium ide 不记录键