Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache mod重写url htaccess_Apache_Url_Rewrite - Fatal编程技术网

Apache mod重写url htaccess

Apache mod重写url htaccess,apache,url,rewrite,Apache,Url,Rewrite,我有点困惑,仍然在学习如何在ApacheHTAccess中重写 我怎样才能扭转这种局面: 为此: 这是我的参考资料,我不确定我做得是否正确 <a href='http://www.mydomain.com/dir1/post.php? id=$id'> 如果只需要重写单个URL,则可以使用简单的重写规则 RewriteRule ^dir1/post.php?%20id=1 category1/post/1 [L] 或者您可能需要将%20替换为空白字符regex Rewrite

我有点困惑,仍然在学习如何在ApacheHTAccess中重写

我怎样才能扭转这种局面:

为此:

这是我的参考资料,我不确定我做得是否正确

<a href='http://www.mydomain.com/dir1/post.php? id=$id'>

如果只需要重写单个URL,则可以使用简单的重写规则

RewriteRule ^dir1/post.php?%20id=1 category1/post/1 [L]
或者您可能需要将%20替换为空白字符regex

RewriteRule ^dir1/post.php?[\s]id=1 category1/post/1 [L]
您需要确保mod_rewrite也处于打开状态(.htaccess中的“RewriteEngine on”)


这里有一个很好的提示:

非常感谢您的帮助,先生,我会试试您给我的建议。。。对不起,英语不好。。。我感谢你的帮助。。godblesshi在那里..又是我我想问一下file.htaccess[在我的例子中它位于/public\u html]的位置是否与它的效果有关?我所做的是。。RewriteRule ^dir1/post.php上的RewriteEngine?%20id=1 category1/post/1[L]尝试将%20替换为[\s]。这是空白字符的正则表达式。如果这不起作用,试试这些建议。