我试图使用htaccess从网址中删除文件夹/文件夹名称 [英] I trying to remove folder/folder name from url using htaccess

查看:105
本文介绍了我试图使用htaccess从网址中删除文件夹/文件夹名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改URL

我的网址

http:// localhost / MotoMate / corporate / company / kenstar
我的目标网址为

http:// localhost / MotoMate / kenstar

I want to change the URL
My Url
http://localhost/MotoMate/corporate/company/kenstar My target url will be
http://localhost/MotoMate/kenstar

**I am using .htacees file:-**

RewriteEngine on 
RewriteBase /MotoMate/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond $1 !^(index\.php|js|img|css|captcha|robots\.txt) 
RewriteRule ^(.*)$ /MotoMate/index.php/$1 [L] 
#AuthType Basic 
#require valid-user 
#Allow valid-user 
#Deny from all 
#Allow from env=test_uri 
#Allow from env=live_url 
#Satisfy any Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^corporate/(.*)$ /$1 [L,NC,R] 
RewriteRule ^company/(.*)$ /$1 [L,NC,R]

但是它不起作用。不变

推荐答案

/Moto/.htaccess 中尝试以下代码:

RewriteEngine on 
RewriteBase /MotoMate/ 

RewriteCond %{THE_REQUEST} /corporate/company/(\S*)\s [NC]
RewriteRule ^ /%1? [R=302,L,NE]

RewriteRule !^corporate/company/ corporate/company/$1 [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond $1 !^(index\.php|js|img|css|captcha|robots\.txt) 
RewriteRule ^(.*)$ index.php/$1 [L] 

这篇关于我试图使用htaccess从网址中删除文件夹/文件夹名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆