gpt4 book ai didi

php - 将 blog-detail.php/{slug} 的 URL 重写为 blog-detail/{slug}

转载 作者:行者123 更新时间:2023-12-04 16:33:34 28 4
gpt4 key购买 nike

我已经成功地将 www.my-website/blog.php 重写为 www.my-website/blog

现在,我想对我的 blog-detail.php 页面做进一步的事情
从 www.my-website/blog-detail.php/how-seo-works 到 www.my-website/blog-detail/how-seo-works

' how-seo-works ' 是我的蛞蝓,它可以是任何东西,取决于文章的标题

当我尝试 时www.my-website/blog-detail/how-seo-works
错误是内部服务器错误

这是我的 htaccess:

# Run Php without filename extension
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php

# Return 404 if original request is .php
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]

错误出现在网站中:

Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at you@example.com to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.



在错误日志中:
AH00124:由于可能的配置错误,请求超出了 10 个内部重定向的限制。如有必要,请使用“LimitInternalRecursion”来增加限制。使用“LogLevel debug”获取回溯。,引用: http://localhost:8080/my-website/blog

最佳答案

我已经解决了这个问题。

所以,这是我修改后的 .htaccess 来访问 my-website/blog-detail/how-seo-work

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^blog-detail/([0-9a-zA-Z-]+) blog-detail.php?id=$1 [L,QSA]

RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]

关于php - 将 blog-detail.php/{slug} 的 URL 重写为 blog-detail/{slug},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61341259/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com