简体   繁体   中英

htaccess | RewriteRule

I am migrating a web site from a Windows Server into a Apache and I like to redict some 404 URLs to correct/equivalent URL in my new server.

What I like to do is to make the following sorten by using RexEx:

Redirect 301 /username/search.asp                /newdir/username/
Redirect 301 /username/contact.asp               /newdir/username/
Redirect 301 /username/legalmarketing.asp        /newdir/username/
Redirect 301 /username/home.asp                  /newdir/username/

I have try to use the RewriteRule with something like that:

RewriteRule ^/username/(search|contact|legalmarketing|home)\.asp$ /newdir/username/ [R=301,L]

Bat this is not working. Any better idea please ? Am I doing something wrong ?

UPDATE #1

I also have try the

RewriteRule ^/username/search.asp$   /newdir/useranme/ [R=301,L]
#as well the following
RewriteRule ^username/search.asp$   /newdir/useranme/ [R=301,L]

but still no chance

UPDATE #2

I also have try this tutorial : http://www.askapache.com/htaccess/crazy-advanced-mod_rewrite-tutorial.html and the problem seems to be more complex, due to null values that I am getting from the server.

This is the code produced by the tutorial code:

Missed These Variables:
Array
(
    [INFO_API_VERSION] => (null)
    [INFO_AUTH_TYPE] => (null)
    [INFO_CONTENT_LENGTH] => (null)
    [INFO_CONTENT_TYPE] => (null)
    [INFO_DOCUMENT_ROOT] => (null)
    [INFO_GATEWAY_INTERFACE] => (null)
    [INFO_HTTPS] => (null)
    [INFO_HTTP_ACCEPT] => (null)
    [INFO_HTTP_ACCEPT_CHARSET] => (null)
    [INFO_HTTP_ACCEPT_ENCODING] => (null)
    [INFO_HTTP_ACCEPT_LANGUAGE] => (null)
    [INFO_HTTP_CACHE_CONTROL] => (null)
    [INFO_HTTP_CONNECTION] => (null)
    [INFO_HTTP_COOKIE] => (null)
    [INFO_HTTP_FORWARDED] => (null)
    [INFO_HTTP_HOST] => (null)
    [INFO_HTTP_KEEP_ALIVE] => (null)
    [INFO_HTTP_MOD_SECURITY_MESSAGE] => (null)
    [INFO_HTTP_PROXY_CONNECTION] => (null)
    [INFO_HTTP_REFERER] => (null)
    [INFO_HTTP_USER_AGENT] => (null)
    [INFO_IS_SUBREQ] => (null)
    [INFO_ORIG_PATH_INFO] => (null)
    [INFO_ORIG_PATH_TRANSLATED] => (null)
    [INFO_ORIG_SCRIPT_FILENAME] => (null)
    [INFO_ORIG_SCRIPT_NAME] => (null)
    [INFO_PATH] => (null)
    [INFO_PATH_INFO] => (null)
    [INFO_PHP_SELF] => (null)
    [INFO_QUERY_STRING] => (null)
    [INFO_REDIRECT_QUERY_STRING] => (null)
    [INFO_REDIRECT_REMOTE_USER] => (null)
    [INFO_REDIRECT_STATUS] => (null)
    [INFO_REDIRECT_URL] => (null)
    [INFO_REMOTE_ADDR] => (null)
    [INFO_REMOTE_HOST] => (null)
    [INFO_REMOTE_IDENT] => (null)
    [INFO_REMOTE_PORT] => (null)
    [INFO_REMOTE_USER] => (null)
    [INFO_REQUEST_FILENAME] => (null)
    [INFO_REQUEST_METHOD] => (null)
    [INFO_REQUEST_TIME] => (null)
    [INFO_REQUEST_URI] => (null)
    [INFO_SCRIPT_FILENAME] => (null)
    [INFO_SCRIPT_GROUP] => (null)
    [INFO_SCRIPT_NAME] => (null)
    [INFO_SCRIPT_URI] => (null)
    [INFO_SCRIPT_URL] => (null)
    [INFO_SCRIPT_USER] => (null)
    [INFO_SERVER_ADDR] => (null)
    [INFO_SERVER_ADMIN] => (null)
    [INFO_SERVER_NAME] => (null)
    [INFO_SERVER_PORT] => (null)
    [INFO_SERVER_PROTOCOL] => (null)
    [INFO_SERVER_SIGNATURE] => (null)
    [INFO_SERVER_SOFTWARE] => (null)
    [INFO_THE_REQUEST] => (null)
    [INFO_TIME] => (null)
    [INFO_TIME_DAY] => (null)
    [INFO_TIME_HOUR] => (null)
    [INFO_TIME_MIN] => (null)
    [INFO_TIME_MON] => (null)
    [INFO_TIME_SEC] => (null)
    [INFO_TIME_WDAY] => (null)
    [INFO_TIME_YEAR] => (null)
    [INFO_TZ] => (null)
    [INFO_UNIQUE_ID] => (null)
)

Any further idea please ?

试试下面的东西

RewriteRule ^username/search.asp$   http://www.yourdomainname.com/newdir/useranme/ [R=301,L]

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