Php .htaccess重写505错误循环
我正试图重写: mydomain.com/category.php?id=cat 到 mydomain.com/cat 我使用了以下.htaccess代码,但它始终显示505错误:Php .htaccess重写505错误循环,php,regex,apache,.htaccess,mod-rewrite,Php,Regex,Apache,.htaccess,Mod Rewrite,我正试图重写: mydomain.com/category.php?id=cat 到 mydomain.com/cat 我使用了以下.htaccess代码,但它始终显示505错误: RewriteEngine On RewriteRule ^([^/]*)$ /category.php?id=$1 [L] 我在另一页上读到,这是因为页面不断循环,但我无法确定如何修复代码。试试这个 <IfModule mod_rewrite.c> RewriteEngine On RewriteBa
RewriteEngine On
RewriteRule ^([^/]*)$ /category.php?id=$1 [L]
我在另一页上读到,这是因为页面不断循环,但我无法确定如何修复代码。试试这个
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(\w+)/ category.php?id=$1 [L]
</IfModule>
重新启动发动机
重写基/
重写规则^(\w+)/category.php?id=$1[L]
您需要添加RewriteCond
以避免对category.php进行重写
RewriteEngine On
RewriteCond %{REQUEUST_URI} !^ /category.php/(.*)
RewriteRule ^(\w+)/ category.php?id=$1 [L]
好的,这应该可以:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/category.php
RewriteRule ^(.*)$ category.php?id=$1 [R=301,L]
演示:保持规则如下:
RewriteEngine On
# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /category.php?id=$1 [L,QSA]
505 HTTP版本不受支持
服务器不支持请求中使用的HTTP协议版本。确定更新了我的答案:)Samething。没有发生任何事情。请检查是否已安装mod_rewrite或未使用php信息。如果是这样的话,它会起作用的。另外,请确保没有任何值为idsToll的文件夹不工作。当我转到页面时,URL显示原样,而不是重写版本。@Flare HOKE刚刚编辑了我的答案,现在应该可以工作了。请注意,您需要添加完整URL和/或R=301标志,以使重写规则显示在URL中并显式显示,否则它将保持隐式。请稍候,看起来我的测试软件是错误的。我会现场测试,以确保它100%的工作,我会回来给你。请原谅。提前非常感谢!:)