url使用.htaccess重写来制作友好的网址

时间:2021-07-15 11:10:01

i have 3 questions regarding .htaccess,

我有3个关于.htaccess的问题,

1- if i use .htaccess to rewrite the url's on my website does it affect any of the requests or do i need to change the link for all forms for example if a action post for a form is index.php?submit do i need to change that link ? when i for example hide .php extension in .htaccess or it doesn't affect it

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

2-how do i basically hide all .php extensions

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

3- if i have the below url

3-如果我有以下网址

www.link.com/post.php?post_id=53&post_name=the-International-day-in-roma

a-)how do i make .htaccess rewrite it to the following

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

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

b-)does it matter if there was commas or can i remove them also ?

b-)如果有逗号或者我可以删除它们是否重要?

www.link.com/post.php?post_id=53&post_name=everyday,-or-today,-or-tomorrow

1 个解决方案

#1


Hope these answers might help :

希望这些答案可能有所帮助

(2) I am responding to the second question first. Use this code in your .HTACCESS file to remove PHP file extensions

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

 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^([^\.]+)$ $1.php [NC,L]

(1) For your first question........you may remove the PHP extensions from the file names. Doesn't change much anyway. Simply makes it easier for YOU, when writing your code.

(1)对于你的第一个问题........你可以从文件名中删除PHP扩展。反正变化不大。在编写代码时,只需简化您的操作。

(3) Try this tutorial :

(3)试试这个教程:

HTACCESS Tutorial

#1


Hope these answers might help :

希望这些答案可能有所帮助

(2) I am responding to the second question first. Use this code in your .HTACCESS file to remove PHP file extensions

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

 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^([^\.]+)$ $1.php [NC,L]

(1) For your first question........you may remove the PHP extensions from the file names. Doesn't change much anyway. Simply makes it easier for YOU, when writing your code.

(1)对于你的第一个问题........你可以从文件名中删除PHP扩展。反正变化不大。在编写代码时,只需简化您的操作。

(3) Try this tutorial :

(3)试试这个教程:

HTACCESS Tutorial