.htaccess htaccess规则,用于将任何特定名称重定向到特定页面

.htaccess htaccess规则,用于将任何特定名称重定向到特定页面,.htaccess,.htaccess,我使用的是PHP,我需要在url中使用一个名为“Pranav dave”,它应该将我重定向到“myprofile.PHP”,我应该怎么做?。。此外,url应该显示我“Pranav dave”。。将任何html文件重定向到php文件的htaccess规则应该是什么?您可以这样做: Options +FollowSymlinks RewriteEngine on RewriteRule ^(.*)$ myprofile.php?profile=$1 [NC] 之后,您可以像这样使用URLhttp:

我使用的是PHP,我需要在url中使用一个名为“Pranav dave”,它应该将我重定向到“myprofile.PHP”,我应该怎么做?。。此外,url应该显示我“Pranav dave”。。将任何html文件重定向到php文件的htaccess规则应该是什么?

您可以这样做:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)$ myprofile.php?profile=$1 [NC]

之后,您可以像这样使用URL
http://example.com/Pranav 戴夫
。唯一的问题是,浏览器将重写url,之后,它看起来像followink one
http://example.com/Pranav%20dave

将任何html文件重定向到php怎么样?我不确定您在想什么,但如果您有一个html文件要重定向,您可以将其用于例如javascript(
window.location=“target.php”
)。但是有很多方法可以解决这个问题。另一个mod_rewrite示例:告诉apache处理html文件,比如php文件(比如:
AddType application/x-httpd-php.html
)等等。