[英]htaccess redirect .htm and .php pages to extensionless
I'm rebuilding an existing website which includes .htm extensions in php. 我正在重建一个现有网站,该网站在php中包含.htm扩展名。 I have the following in my .htaccess file so that .php files are extensionless but how do I redirect any potential .htm pages to the extentionless .php page?
我的.htaccess文件中包含以下内容,因此.php文件是无扩展名的,但是如何将任何潜在的.htm页面重定向至无扩展名的.php页面?
<IfModule mod_rewrite.c>
RewriteEngine On
AddType application/x-httpd-php .php .htm .html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]
</IfModule>
Try this in your .htaccess file 在您的.htaccess文件中尝试一下
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9_-]+)(.htm)?$ $1.php [L,QSA]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.