简体   繁体   English

使用PHP中的端口号和根文件夹进行URL重写

[英]URL Rewriting with port number and root folder in PHP

I have written URL rewrite like this 我写了这样的URL重写

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^home index.php

RewriteRule ^process login_do.php
RewriteRule ^logout logout.php
RewriteRule ^request event-request.php
RewriteRule ^gallery event-gallery.php
RewriteRule ^press-releases/([0-9]+)$ press_releases.php?y=$1
RewriteRule ^single_pr/([0-9]+)$ single_pr.php?id=$1

and it is working perfectly on IIS server after converting this into webconfig but when I deployed my application on XAMPP Linux it is not working and showing, REDIRECT loop on browser. 并将其转换为webconfig后,它在IIS服务器上可以正常工作,但是当我在XAMPP Linux上部署我的应用程序时,它无法工作并在浏览器上显示REDIRECT循环。

Can anyone guide me how to add port number and folder name in the URL rewrite, because I think IIS is considering localhost/myapplicaiton as localhost/index.php so that is why it is working in IIS. 谁能指导我如何在URL重写中添加端口号和文件夹名称,因为我认为IIS正在将localhost / myapplicaiton视为localhost / index.php,因此这就是它在IIS中运行的原因。 Guide me for Linux and Windows. 指导我使用Linux和Windows。

I have found the solution, issue was related to mod_rewrite function was disabled in apache in linux operating system. 我找到了解决方案,该问题与在Linux操作系统中的Apache中禁用了mod_rewrite函数有关。 To find out mod_rewrite is enabled or disabled. 要找出mod_rewrite是启用还是禁用。 just run php_info() and search for mod_rewrite . 只需运行php_info()并搜索mod_rewrite this is an easy technique, there are multiple ways to find out mod_rewrite. 这是一项简单的技术,有多种方法可以找出mod_rewrite。 To enable mod_rewrite , go to your linux terminal and type this command a2enmod rewrite and restart apache php_info() . 要启用mod_rewrite ,请转到您的Linux终端,然后键入以下命令a2enmod rewrite并重新启动apache php_info()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM