My.htaccess pretty url不工作,该url位于localhost(具有xampp的本地计算机)中

My.htaccess pretty url不工作,该url位于localhost(具有xampp的本地计算机)中,.htaccess,url-rewriting,.htaccess,Url Rewriting,我需要重写此url: http://localhost/blog/post.php?id=48 进入 http://localhost/blog/post/48 它位于我的xampp的localhost中。 我已经创建了.htaccess文件并编写了以下代码 <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_

我需要重写此url:
http://localhost/blog/post.php?id=48
进入
http://localhost/blog/post/48
它位于我的xampp的localhost中。 我已经创建了.htaccess文件并编写了以下代码

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^post/([0-9]+)/?$ post.php?id=$1 [NC,L]
</IfModule>

重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^post/([0-9]+)/?$post.php?id=$1[NC,L]

我尝试过重定向和所有其他东西。一切都正常,但我的重写规则本身不起作用。我已经搜索并尝试了所有的选择,但没有成功。请有人帮我解决这个问题

你的问题是
^post
,这意味着post是你人生道路的第一部分,而blog不是。您是否尝试过
^blog/post…

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/post/([0-9]+)/?$ blog/post.php?id=$1 [NC,L]
</IfModule>

重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^blog/post/([0-9]+)/?$blog/post.php?id=$1[NC,L]

最后,它将使用以下代码:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/ # This is the thing which made me struck with this
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^post/([0-9]+)/?$ post.php?id=$1 [NC,QSA]
</IfModule>

重新启动发动机
RewriteBase/blog/#正是这件事让我震惊
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^post/([0-9]+)/?$post.php?id=$1[NC,QSA]

不要污染标签。你的问题根本与PHP无关。标签去掉了,我也做了。但没有用…它仍然显示相同的url!这是因为我的xampp中存在配置问题吗?啊,是的,这是有道理的。我认为我的答案有点错——我用我认为有效的方法编辑了它,但你的方法也完全正确:)