Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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
Php 使用.htaccess重写url以生成友好url_Php_Apache_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

Php 使用.htaccess重写url以生成友好url

Php 使用.htaccess重写url以生成友好url,php,apache,.htaccess,mod-rewrite,url-rewriting,Php,Apache,.htaccess,Mod Rewrite,Url Rewriting,我有3个关于.htaccess的问题 1-如果我使用.htaccess重写我网站上的url,是否会影响任何请求,或者我是否需要更改所有表单的链接(例如,如果表单的操作帖子是index.php)?提交我是否需要更改该链接?例如,当我在.htaccess中隐藏.php扩展名时,或者它不影响它 2-如何基本上隐藏所有.php扩展 3-如果我有下面的url www.link.com/post.php?post_id=53&post_name=罗马国际日 a-)如何使.htaccess重写为以下内容 ww

我有3个关于.htaccess的问题

1-如果我使用.htaccess重写我网站上的url,是否会影响任何请求,或者我是否需要更改所有表单的链接(例如,如果表单的操作帖子是index.php)?提交我是否需要更改该链接?例如,当我在.htaccess中隐藏.php扩展名时,或者它不影响它

2-如何基本上隐藏所有.php扩展

3-如果我有下面的url

www.link.com/post.php?post_id=53&post_name=罗马国际日

a-)如何使.htaccess重写为以下内容

www.link.com/post/the-International-day-in-roma

b-)是否有逗号或我是否可以删除它们


www.link.com/post.php?post_id=53&post_name=Daily,-或今天,-或明天希望这些答案能有所帮助:

(2) 我首先回答第二个问题。在.HTACCESS文件中使用此代码删除PHP文件扩展名

 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^([^\.]+)$ $1.php [NC,L]
(1) 对于您的第一个问题……。您可以从文件名中删除PHP扩展名。反正变化不大。在编写代码时,只需简单地简化即可

(3) 尝试以下教程:


请每个线程回答一个问题您能回答我的第三个问题吗@anubhavaSorry第三个要求很难,因为postId
53
不是原始URL
www.link.com/post/the International day in roma
,因此无法重写为
www.link.com/post.php?post_id=53&post_name=罗马国际日
那么我需要做什么?删除post_id=。。那我就可以重写了?如果是,怎么做@在
post.php
中需要使用anubhava
post\u id
进行查找。你可以有一个漂亮的网址:
www.link.com/post/53/罗马国际日