swappy
swappy

Reputation: 135

.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!

Upvotes: 0

Views: 113

Answers (2)

umka
umka

Reputation: 1655

Just add

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

to your www-root .htaccess. Nothing more.

Upvotes: 0

Birdy
Birdy

Reputation: 773

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

Upvotes: 1

Related Questions