gpt4 book ai didi

apache - htaccess 在我尝试打开页面时显示错误

转载 作者:行者123 更新时间:2023-12-05 01:35:07 24 4
gpt4 key购买 nike

我有两个页面,我正在尝试为这些链接创建美观的 url。第一个链接:-

http://www.themobilesapp.com/tags.php?tag=Android

用于将此 url 转换为此 url。

http://www.themobilesapp.com/tag/Android

为此,我编写了这段代码。

RewriteRule ^tag/([A-Za-z0-9-]+)?$ tags.php?tag=$1 [L]

第二个链接:-

http://www.themobilesapp.com/phones.php?title=Apple

用于将此 url 转换为此 url。

http://www.themobilesapp.com/brand/Android

为此,我编写了这段代码。

RewriteRule ^brand/([A-Za-z0-9-]+)?$ phones.php?title=$1 [L]

但是在两个页面上都出现了一个相同的错误。这个错误出现在我的页面上内部服务器错误

我的整个 htaccess 文件代码是

Options +FollowSymLinks -MultiViews -Indexes
Options -Multiviews

<IfModule mod_rewrite.c>

DirectoryIndex index.php

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

ErrorDocument 404 404error.php

RewriteRule ^([A-Za-z0-9-]+)?$ specification.php?url=$1 [L]

RewriteRule ^news/([A-Za-z0-9-]+)?$ news.php?url=$1 [L]

RewriteRule ^social/([A-Za-z0-9-]+)?$ social.php?url=$1 [L]

RewriteRule ^tag/([A-Za-z0-9-]+)?$ tags.php?tag=$1 [L]

RewriteRule ^brand/([A-Za-z0-9-]+)?$ phones.php?title=$1 [L]

</IfModule>

除以下两个外,所有 RewriteRule 规则均有效。

最佳答案

请检查拼写并确保文件存在,尝试使用以下简化规则。

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#after above rewrite cond use below rewrite for each page in below manner
RewriteRule ^tags/([\w-]+)$ tags.php?tag=$1 [L]

关于apache - htaccess 在我尝试打开页面时显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42506906/

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