【发布时间】:2015-04-12 02:05:59
【问题描述】:
这是我的 .htaccess 文件,到目前为止一切正常,但我无法从文件中删除 .php 扩展名,我从其他答案中尝试的每个代码都抛出了 500 或 404 错误。请告知在哪里以及添加什么。文件夹的结构是 localhost/myfolder/somefile.php
明确一点 - localhost/myfolder/ 是我项目的根目录。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ /myfolder/$1/ [L,R=301]
RewriteRule ^team-news/([0-9]+[/])?$ posts.php?p=$1&cat=Team\ News
RewriteRule ^product-news/([0-9]+[/])?$ posts.php? p=$1&cat=Product\ News
RewriteRule ^member-specials/([0-9]+[/])?$ posts.php?p=$1&cat=Member\ Specials
RewriteRule ^ambassador-blogs/([0-9]+[/])?$ posts.php?p=$1&cat=Ambassador\ Blogs
RewriteRule ^user/([0-9]+[/])?$ profile.php?id=$1
RewriteRule ^browse-all/([0-9]+[/])?$ searchall.php?p=$1
RewriteRule ^edit/([0-9]+[/])?$ edit.php?id=$1
RewriteRule ^articles/([0-9]+[/])?$ post.php?id=$1
【问题讨论】:
-
不知道你做错了什么,但有一些像this这样的工具可能会帮助你..
-
您能否说明错误是什么以及哪个 URL 不起作用?
-
这里发布的代码一切正常,但现在我需要插入一个从文件中删除 .php 的部分,而无论我尝试什么都行不通。
标签: php apache .htaccess mod-rewrite