【发布时间】:2016-08-14 07:35:12
【问题描述】:
我想从 url 中删除文件名和扩展名,我有一个目录 (Blogs) 和其中的两个文件 (Main_blogs.php) 和 (Blog.php)
localhost/SikandarIqbal.net/blogs/
当我在“博客”目录中打开 Main_blog.php 时,我得到了上面的 url,我可以通过这个 htaccess 文件获得:
DirectorySlash Off
DirectoryIndex disabled
RewriteEngine on
# prevent direct access to PHP files
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule \.php$ - [R=404,L]
# rewrite requests for a directory to index.php
RewriteCond %{REQUEST_FILENAME}/Main_blogs.php -f
RewriteRule ^.*$ $0/Main_blogs.php [L]
当我从 Main_blog.php 打开一个特定的博客时,网址变成了
localhost/Sikandariqbal.net/Blogs/Blog.php/My-Blog-name
我真正想要的是成为某种东西
localhost/Sikandariqbal.net/Blogs/My-Blog-name
删除 /Blogs/ 和 /My-Blog-name 之间的文件名 Blog.php
请帮忙!
谢谢
【问题讨论】: