简体   繁体   中英

mod rewrite .htaccess URL redirect

I want to simply point the www.mysite.com/corporate to www.mysite.com/services/corporate

here is my .htaccess:

#DirectoryIndex index.php index.html
#Options +FollowSymLinks
#Options -Indexes
#ErrorDocument 403 default

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
        RewriteRule ^corporate$ services/corporate
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^(.+) - [PT,L]

    RewriteCond %{REQUEST_URI} !=/favicon.ico
    RewriteRule ^(.*) index.php

    RewriteCond %{HTTP:Authorization}  !^$
    RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

#php_value register_globals 0

Use mod_rewrite. Place something like this in .htaccess in the root directory:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)/corporate/(.*)$ $1/services/corporate/$2 [R,L] 

See http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html for more info.

难以理解您的.htaccess代码的某些部分,但是您可以在</IfModule>之前添加一行:

RewriteRule ^corporate/?$ services/corporate [NC,L,R=301]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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