我有两个页面,我试图为这些链接制作好看的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规则都是有效的。
发布于 2017-02-28 11:27:36
请检查拼写,并确保文件存在,尝试使用以下简化规则。
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]https://stackoverflow.com/questions/42506906
复制相似问题