我尝试使用htaccess从url中删除文件夹/文件夹名称

时间:2016-04-21 08:42:31

标签: .htaccess

我想更改网址
我的网址
     http://localhost/MotoMate/corporate/company/kenstar     我的目标网址
       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]

但它不起作用。不改变

1 个答案:

答案 0 :(得分:0)

/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]