简体   繁体   中英

Redirect sub domain to other IP address without changing sub domain name getting internal server error

I want to redirect from domain_name/directory_name/file_name/ to http://xx.xx.xx.x/project_name/controller/ but in URL I want to show domain_name/directory_name/file_name/. For that I write following code in .htaccess file

  RewriteEngine On
  RewriteCond %{HTTP_HOST} !directory_name/file_name/$ [NC]
  RewriteRule ^(.*)$ http://xx.xx.xx.x/project_name/controller/$1 [P]

When I write

  RewriteEngine On
  RewriteCond %{HTTP_HOST} !directory_name/file_name/$ [NC]
  RewriteRule ^(.*)$ http://xx.xx.xx.x/project_name/controller/$1 [L,R=301]

Then it is redirect from directory_name/file_name/ to http://xx.xx.xx.x/project_name/controller/ but showing http://xx.xx.xx.x/project_name/controller/ in URL.

For that I change [L,R=301] to [P] as the reference of http://www.inmotionhosting.com/support/website/htaccess/redirect-without-changing-url site but it gives me following error

 Internal Server Error

 The server encountered an internal error or misconfiguration and was unable   to complete your request.

 Please contact the server administrator at admin@example.com to inform them of the time this error occurred, and the actions you performed just before this error.

 More information about this error may be available in the server error log.

Please help me.It would be great help.

I got an answer. Just enable your mod_proxy_http Apache module.

  Go to your httpd.conf file and uncomment proxy_http_module
  Restart wamp

Reference - .htacess rewriting with the [P] proxy flag

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