.htaccess 使用htaccess重写URL-如何显示假URL?

.htaccess 使用htaccess重写URL-如何显示假URL?,.htaccess,url-rewriting,.htaccess,Url Rewriting,我在htacces文件中有这样的代码 <IfModule mod_rewrite.c> RewriteEngine on # this stops looping RewriteCond %{ENV:REDIRECT_STATUS} 200 RewriteRule ^ - [L] # this redirects the browser: RewriteRule !^/?UL/india/ /UL/india/ [L,R=301] RewriteRule ^/?UL/india/ /

我在htacces文件中有这样的代码

<IfModule mod_rewrite.c>
RewriteEngine on
# this stops looping
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
# this redirects the browser:
RewriteRule !^/?UL/india/ /UL/india/ [L,R=301]
RewriteRule ^/?UL/india/ /UL/index.php [L]
</IfModule>

重新启动发动机
#这会停止循环
RewriteCond%{ENV:REDIRECT_STATUS}200
重写规则^-[L]
#这将重定向浏览器:
重写规则!^/?UL/印度//UL/印度/[L,R=301]
重写规则^/?UL/india//UL/index.php[L]
但是当访问
localhost/UL/
时,它不断显示“页面没有正确重定向”。有什么问题

我想在地址栏中为每个到UL目录的请求显示
localhost/UL/india/


但是应该执行的文件是
localhost/UL/index.php

在规则中添加
L
标志并停止循环:

# this stops looping
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]

# this redirects the browser:
RewriteRule !^/?UL/india/ /UL/india/ [L,R=301]
然后,在此之后,您希望匹配
/UL/india/
,并提供index.php文件:

RewriteRule ^/?UL/india/ /UL/index.php [L]

我的要求是,当用户输入localhost/UL/时,它应该重定向到localhost/UL/india/但应该执行文件localhost/UL/index.php…help me..提供完整代码..@FrancisMV123我在回答中提供了“完整代码”。你没试过吗?@FrancisMV123它显示“
”?我将所有这些行放在一个空白的htaccess文件中(以及
上的RewriteEngine),然后点击Web服务器上的任何URL,浏览器的URL地址栏显示
http://localhost/UL/india/
我收到了
/UL/index.php
@FrancisMV123的内容编辑您的问题并发布您的htaccess文件,因为这些规则对我来说非常好。@FrancisMV123这些规则对我来说非常好。您确定已加载“重写”模块吗?否则,删除
行将导致错误。您确定在服务器/vhost配置中设置了
AllowOverride All
?否则,您的htaccess文件将被完全忽略。