简体   繁体   中英

.htaccess file not working at all

I am trying to redirect anyone when he is trying to hit "192.168.21.3:8080/ping" to "192.168.21.3:8080/ping.php" via creating a .htaccess file with following code in it:

//301 Redirect Old File
Redirect 301 http://192.168.1.234:8080/ping http://192.168.1.234:8080/ping.php

Also, following line in httpd.conf has been un-commentated:

LoadModule rewrite_module modules/mod_rewrite.so

Please help!

i am still learning the basics myself however i will have a try to help you out, If you let me know how you get on.. i can re-edit my answer should the solution not work.

You can either redirect all traffic to the page named ping.php or as per your question you can redirect a specific IP address to ping.php.

add the code below to your .htaccess file.

RewriteEngine On
RewriteCond %{REMOTE_ADDR} 192\.168\.21\.3
RewriteCond %{REQUEST_URI} !/ping\.php$
RewriteRule $ /ping.php[R=301,L]

Alternatively you could take a look here as this may also help you out: https://perishablepress.com/permanently-redirect-a-specific-ip-request-for-a-single-page-via-htaccess/

Thanks

Just add

RedirectMatch ^/ping$ http://192.168.1.234:8080/ping.php

to your www-root .htaccess . Nothing more.

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