Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
.htaccess 重定向原始url以重写url(htaccess)_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess 重定向原始url以重写url(htaccess)

.htaccess 重定向原始url以重写url(htaccess),.htaccess,mod-rewrite,.htaccess,Mod Rewrite,如何重定向原始url以重写url 原始: domain/index.php?p=50 重写: 域名/邮政/50/ 我试着在这里更好地解释 如果 请求:domain/index.php?p=50 重定向到:域/post/50/ 重写为:domain/index.php?p=50 感谢您使用此代码: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-

如何重定向原始url以重写url

原始: domain/index.php?p=50 重写: 域名/邮政/50/

我试着在这里更好地解释

如果

请求:domain/index.php?p=50

重定向到:域/post/50/

重写为:domain/index.php?p=50

感谢您使用此代码:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^post/([0-9]+)$ index.php?p=$1 [L]
你必须以另一种方式思考:

  • 用户将使用domain/post/50
  • 我将把这个url重写为domain/index.php?p=50