URL重新写入内部服务器错误

时间:2018-08-24 09:53:30

标签: php .htaccess

我正在尝试在我的类别页面上重写一个网址。

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]

其他规则正在发挥作用

1 个答案:

答案 0 :(得分:0)

更改顺序:

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]