Php 是否可以将我的htaccess重写规则压缩为单行规则?
我的Webproject中的所有htaccess规则都起作用。然而,我想知道是否有办法使用REGEX编写一条规则,而不是像下面所示对它们进行硬编码。我在上找不到问题/答案,因此无法满足此处提到的需求。谢谢你的建议和帮助Php 是否可以将我的htaccess重写规则压缩为单行规则?,php,.htaccess,url-rewriting,Php,.htaccess,Url Rewriting,我的Webproject中的所有htaccess规则都起作用。然而,我想知道是否有办法使用REGEX编写一条规则,而不是像下面所示对它们进行硬编码。我在上找不到问题/答案,因此无法满足此处提到的需求。谢谢你的建议和帮助 RewriteEngine on RewriteRule ^index index.php RewriteRule ^about-us about-us.php
RewriteEngine on
RewriteRule ^index index.php
RewriteRule ^about-us about-us.php
RewriteRule ^web-application-development web-application-development.php
RewriteRule ^mobile-application-development mobile-application-development.php
RewriteRule ^offshoring offshoring.php
RewriteRule ^internet-marketing internet-marketing.php
RewriteRule ^careers careers.php
RewriteRule ^blog blog.php
RewriteRule ^contact-us contact-us.php
我正在寻找一个涉及REGEX的单一规则,它完成上述所有规则组合在一起时所做的工作。您可以使用这个单一规则重写您的.php请求
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ /$1.php [L]
或者,您可以启用多视图来访问不带扩展名的文件,将以下行添加到htaccess中
Options +Multiviews
非常感谢的可能的副本你的要简单得多。伟大的