htaccess当我尝试打开页面时显示错误 [英] htaccess showing error when I try to open page
问题描述
我有两个页面,我正在尝试为这些链接添加漂亮的URL. 第一个链接:-
I have two page and I'm trying to make good looking url for these links. First link :-
http://www.themobilesapp.com/tags.php? tag = Android
http://www.themobilesapp.com/tags.php?tag=Android
用于将该网址转换为该网址.
for to convert this url into this url.
http://www.themobilesapp.com/tag/Android
http://www.themobilesapp.com/tag/Android
为此,我编写了这段代码.
for this i write this code.
RewriteRule ^tag/([A-Za-z0-9-]+)?$ tags.php?tag=$1 [L]
第二个链接:-
http://www.themobilesapp.com/phones.php? title =苹果
http://www.themobilesapp.com/phones.php?title=Apple
用于将该网址转换为该网址.
for to convert this url into this url.
http://www.themobilesapp.com/brand/Android
http://www.themobilesapp.com/brand/Android
为此,我编写了这段代码.
for this i write this code.
RewriteRule ^brand/([A-Za-z0-9-]+)?$ phones.php?title=$1 [L]
但是在两个页面上都会出现一个相同的错误. 此错误即将出现在我的页面上 内部服务器错误
But on both pages one same error is coming. This error is coming on my page Internal Server Error
我的整个htaccess文件代码是
and my whole htaccess file code is
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规则均有效.
All RewriteRule rules are working except below two.
推荐答案
请检查拼写并确保文件存在,请尝试使用以下简化规则.
Please check for spellings and make sure file exist, try to use below simplified rule.
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]
这篇关于htaccess当我尝试打开页面时显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!