配置php .htaccess文件
我对HTACCESS配置的工作方式不太了解,我正在努力编写一个配置,该配置负责以下两个方案: -
- 无需.php扩展名的服务器php页面请求,
- 而无需重定向,例如重新写入URL https://example.com/success/24
为了适应第二种情况,我要使用第一个配置。我在.htaccess文件中使用的代码如下: -
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9_-]+)$ /index.php?q=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?q=$1
请有人协助我应该如何容纳两种情况。
I don't know much on how htaccess configuration works and I'm struggling to write a configuration that takes care of two scenarios below:-
- server php pages request without .php extension
- rewrite the url without redirecting, for instance, rewrite
https://example.com/success/24 to https://example.com?response=success&id=24
-Taking care of the first scenario is straight forward but on trying to accommodate the second scenario I'm messing with the first configuration. The code i'm using in the .htaccess file is as follows:-
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9_-]+)$ /index.php?q=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?q=$1
Please someone assist on how I should accommodate the two use scenarios.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于第一种情况,
这是.htacess的代码
For the first scenario
this is code for .htacess